src/hotspot/share/memory/heapShared.hpp
author redestad
Thu, 20 Dec 2018 19:44:08 +0100
changeset 53091 5bf5b773fc41
parent 52514 f4e3900c8d08
child 53244 9807daeb47c4
permissions -rw-r--r--
8215555: TieredCompilation C2 threads can excessively block handshakes Reviewed-by: kvn, neliasso, rehn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
     1
/*
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
     4
 *
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
     7
 * published by the Free Software Foundation.
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
     8
 *
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    13
 * accompanied this code).
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    14
 *
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    18
 *
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    21
 * questions.
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    22
 *
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    23
 */
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    24
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    25
#ifndef SHARE_VM_MEMORY_HEAPSHARED_HPP
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    26
#define SHARE_VM_MEMORY_HEAPSHARED_HPP
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    27
52047
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
    28
#include "classfile/compactHashtable.hpp"
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    29
#include "classfile/systemDictionary.hpp"
51701
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
    30
#include "memory/allocation.hpp"
52402
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
    31
#include "memory/metaspaceShared.hpp"
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    32
#include "memory/universe.hpp"
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    33
#include "oops/objArrayKlass.hpp"
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    34
#include "oops/oop.hpp"
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    35
#include "oops/typeArrayKlass.hpp"
51491
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 51429
diff changeset
    36
#include "utilities/bitMap.hpp"
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    37
#include "utilities/growableArray.hpp"
51701
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
    38
#include "utilities/resourceHash.hpp"
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    39
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    40
#if INCLUDE_CDS_JAVA_HEAP
52402
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
    41
struct ArchivableStaticFieldInfo {
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
    42
  const char* klass_name;
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
    43
  const char* field_name;
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
    44
  InstanceKlass* klass;
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
    45
  int offset;
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
    46
  BasicType type;
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
    47
};
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
    48
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    49
// A dump time sub-graph info for Klass _k. It includes the entry points
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    50
// (static fields in _k's mirror) of the archived sub-graphs reachable
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    51
// from _k's mirror. It also contains a list of Klasses of the objects
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    52
// within the sub-graphs.
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    53
class KlassSubGraphInfo: public CHeapObj<mtClass> {
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    54
 private:
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    55
  // The class that contains the static field(s) as the entry point(s)
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    56
  // of archived object sub-graph(s).
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    57
  Klass* _k;
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    58
  // A list of classes need to be loaded and initialized before the archived
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    59
  // object sub-graphs can be accessed at runtime.
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    60
  GrowableArray<Klass*>* _subgraph_object_klasses;
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    61
  // A list of _k's static fields as the entry points of archived sub-graphs.
52402
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
    62
  // For each entry field, it is a tuple of field_offset, field_value and
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
    63
  // is_closed_archive flag.
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    64
  GrowableArray<juint>*  _subgraph_entry_fields;
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    65
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    66
 public:
52047
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
    67
  KlassSubGraphInfo(Klass* k) :
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
    68
    _k(k),  _subgraph_object_klasses(NULL),
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    69
    _subgraph_entry_fields(NULL) {}
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    70
  ~KlassSubGraphInfo() {
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    71
    if (_subgraph_object_klasses != NULL) {
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    72
      delete _subgraph_object_klasses;
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    73
    }
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    74
    if (_subgraph_entry_fields != NULL) {
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    75
      delete _subgraph_entry_fields;
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    76
    }
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    77
  };
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    78
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    79
  Klass* klass()            { return _k; }
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    80
  GrowableArray<Klass*>* subgraph_object_klasses() {
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    81
    return _subgraph_object_klasses;
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    82
  }
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    83
  GrowableArray<juint>*  subgraph_entry_fields() {
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    84
    return _subgraph_entry_fields;
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    85
  }
52402
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
    86
  void add_subgraph_entry_field(int static_field_offset, oop v,
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
    87
                                bool is_closed_archive);
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    88
  void add_subgraph_object_klass(Klass *orig_k, Klass *relocated_k);
51701
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
    89
  int num_subgraph_object_klasses() {
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
    90
    return _subgraph_object_klasses == NULL ? 0 :
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
    91
           _subgraph_object_klasses->length();
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
    92
  }
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    93
};
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    94
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    95
// An archived record of object sub-graphs reachable from static
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    96
// fields within _k's mirror. The record is reloaded from the archive
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    97
// at runtime.
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    98
class ArchivedKlassSubGraphInfoRecord {
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
    99
 private:
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   100
  Klass* _k;
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   101
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   102
  // contains pairs of field offset and value for each subgraph entry field
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   103
  Array<juint>* _entry_field_records;
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   104
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   105
  // klasses of objects in archived sub-graphs referenced from the entry points
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   106
  // (static fields) in the containing class
51701
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   107
  Array<Klass*>* _subgraph_object_klasses;
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   108
 public:
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   109
  ArchivedKlassSubGraphInfoRecord() :
52047
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   110
    _k(NULL), _entry_field_records(NULL), _subgraph_object_klasses(NULL) {}
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   111
  void init(KlassSubGraphInfo* info);
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52402
diff changeset
   112
  Klass* klass() const { return _k; }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52402
diff changeset
   113
  Array<juint>*  entry_field_records() const { return _entry_field_records; }
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52402
diff changeset
   114
  Array<Klass*>* subgraph_object_klasses() const { return _subgraph_object_klasses; }
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   115
};
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   116
#endif // INCLUDE_CDS_JAVA_HEAP
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   117
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   118
class HeapShared: AllStatic {
51701
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   119
  friend class VerifySharedOopClosure;
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   120
 private:
52062
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   121
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   122
#if INCLUDE_CDS_JAVA_HEAP
52402
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   123
  static bool _closed_archive_heap_region_mapped;
52062
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   124
  static bool _open_archive_heap_region_mapped;
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   125
  static bool _archive_heap_region_fixed;
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   126
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   127
  static bool oop_equals(oop const& p1, oop const& p2) {
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   128
    return oopDesc::equals(p1, p2);
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   129
  }
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   130
  static unsigned oop_hash(oop const& p);
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   131
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   132
  typedef ResourceHashtable<oop, oop,
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   133
      HeapShared::oop_hash,
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   134
      HeapShared::oop_equals,
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   135
      15889, // prime number
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   136
      ResourceObj::C_HEAP> ArchivedObjectCache;
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   137
  static ArchivedObjectCache* _archived_object_cache;
52047
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   138
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   139
  static bool klass_equals(Klass* const& p1, Klass* const& p2) {
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   140
    return primitive_equals<Klass*>(p1, p2);
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   141
  }
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   142
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   143
  static unsigned klass_hash(Klass* const& klass) {
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   144
    return primitive_hash<address>((address)klass);
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   145
  }
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   146
52047
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   147
  class DumpTimeKlassSubGraphInfoTable
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   148
    : public ResourceHashtable<Klass*, KlassSubGraphInfo,
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   149
                               HeapShared::klass_hash,
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   150
                               HeapShared::klass_equals,
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   151
                               137, // prime number
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   152
                               ResourceObj::C_HEAP> {
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   153
  public:
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   154
    int _count;
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   155
  };
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   156
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52402
diff changeset
   157
public: // solaris compiler wants this for RunTimeKlassSubGraphInfoTable
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52402
diff changeset
   158
  inline static bool record_equals_compact_hashtable_entry(
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52402
diff changeset
   159
       const ArchivedKlassSubGraphInfoRecord* value, const Klass* key, int len_unused) {
52047
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   160
    return (value->klass() == key);
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   161
  }
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   162
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52402
diff changeset
   163
private:
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52402
diff changeset
   164
  typedef OffsetCompactHashtable<
52047
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   165
    const Klass*,
52514
f4e3900c8d08 8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents: 52402
diff changeset
   166
    const ArchivedKlassSubGraphInfoRecord*,
52047
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   167
    record_equals_compact_hashtable_entry
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   168
    > RunTimeKlassSubGraphInfoTable;
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   169
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   170
  static DumpTimeKlassSubGraphInfoTable* _dump_time_subgraph_info_table;
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   171
  static RunTimeKlassSubGraphInfoTable _run_time_subgraph_info_table;
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   172
52402
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   173
  static void check_closed_archive_heap_region_object(InstanceKlass* k,
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   174
                                                      Thread* THREAD);
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   175
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   176
  static void archive_object_subgraphs(ArchivableStaticFieldInfo fields[],
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   177
                                       int num,
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   178
                                       bool is_closed_archive,
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   179
                                       Thread* THREAD);
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   180
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   181
  // Archive object sub-graph starting from the given static field
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   182
  // in Klass k's mirror.
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   183
  static void archive_reachable_objects_from_static_field(
51701
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   184
    InstanceKlass* k, const char* klass_name,
52402
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   185
    int field_offset, const char* field_name,
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   186
    bool is_closed_archive, TRAPS);
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   187
51701
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   188
  static void verify_subgraph_from_static_field(
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   189
    InstanceKlass* k, int field_offset) PRODUCT_RETURN;
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   190
  static void verify_reachable_objects_from(oop obj, bool is_archived) PRODUCT_RETURN;
52402
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   191
  static void verify_subgraph_from(oop orig_obj) PRODUCT_RETURN;
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   192
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   193
  static KlassSubGraphInfo* get_subgraph_info(Klass *k);
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   194
  static int num_of_subgraph_infos();
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   195
52047
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   196
  static void build_archived_subgraph_info_records(int num_records);
51491
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 51429
diff changeset
   197
52402
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   198
  static void init_subgraph_entry_fields(ArchivableStaticFieldInfo fields[],
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   199
                                         int num, Thread* THREAD);
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   200
51720
b7bfd64e43a6 8210523: runtime/appcds/cacheObject/DifferentHeapSizes.java crash
iklam
parents: 51701
diff changeset
   201
  // Used by decode_from_archive
51491
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 51429
diff changeset
   202
  static address _narrow_oop_base;
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 51429
diff changeset
   203
  static int     _narrow_oop_shift;
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 51429
diff changeset
   204
51701
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   205
  typedef ResourceHashtable<oop, bool,
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   206
      HeapShared::oop_hash,
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   207
      HeapShared::oop_equals,
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   208
      15889, // prime number
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   209
      ResourceObj::C_HEAP> SeenObjectsTable;
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   210
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   211
  static SeenObjectsTable *_seen_objects_table;
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   212
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   213
  static void init_seen_objects_table() {
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   214
    assert(_seen_objects_table == NULL, "must be");
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   215
    _seen_objects_table = new (ResourceObj::C_HEAP, mtClass)SeenObjectsTable();
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   216
  }
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   217
  static void delete_seen_objects_table() {
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   218
    assert(_seen_objects_table != NULL, "must be");
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   219
    delete _seen_objects_table;
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   220
    _seen_objects_table = NULL;
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   221
  }
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   222
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   223
  // Statistics (for one round of start_recording_subgraph ... done_recording_subgraph)
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   224
  static int _num_new_walked_objs;
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   225
  static int _num_new_archived_objs;
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   226
  static int _num_old_recorded_klasses;
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   227
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   228
  // Statistics (for all archived subgraphs)
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   229
  static int _num_total_subgraph_recordings;
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   230
  static int _num_total_walked_objs;
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   231
  static int _num_total_archived_objs;
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   232
  static int _num_total_recorded_klasses;
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   233
  static int _num_total_verifications;
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   234
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   235
  static void start_recording_subgraph(InstanceKlass *k, const char* klass_name);
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   236
  static void done_recording_subgraph(InstanceKlass *k, const char* klass_name);
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   237
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   238
  static bool has_been_seen_during_subgraph_recording(oop obj);
9012aeaf993b 8210289: ArchivedKlassSubGraphInfoRecord is incomplete
iklam
parents: 51491
diff changeset
   239
  static void set_has_been_seen_during_subgraph_recording(oop obj);
52062
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   240
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   241
 public:
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   242
  static void create_archived_object_cache() {
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   243
    _archived_object_cache =
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   244
      new (ResourceObj::C_HEAP, mtClass)ArchivedObjectCache();
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   245
  }
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   246
  static void destroy_archived_object_cache() {
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   247
    delete _archived_object_cache;
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   248
    _archived_object_cache = NULL;
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   249
  }
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   250
  static ArchivedObjectCache* archived_object_cache() {
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   251
    return _archived_object_cache;
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   252
  }
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   253
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   254
  static oop find_archived_heap_object(oop obj);
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   255
  static oop archive_heap_object(oop obj, Thread* THREAD);
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   256
  static oop materialize_archived_object(narrowOop v);
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   257
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   258
  static void archive_klass_objects(Thread* THREAD);
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   259
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   260
  static void set_archive_heap_region_fixed() {
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   261
    _archive_heap_region_fixed = true;
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   262
  }
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   263
  static bool archive_heap_region_fixed() {
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   264
    return _archive_heap_region_fixed;
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   265
  }
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   266
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   267
  static void archive_java_heap_objects(GrowableArray<MemRegion> *closed,
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   268
                                        GrowableArray<MemRegion> *open);
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   269
  static void copy_closed_archive_heap_objects(GrowableArray<MemRegion> * closed_archive);
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   270
  static void copy_open_archive_heap_objects(GrowableArray<MemRegion> * open_archive);
52402
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   271
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   272
  static oop archive_reachable_objects_from(int level,
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   273
                                            KlassSubGraphInfo* subgraph_info,
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   274
                                            oop orig_obj,
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   275
                                            bool is_closed_archive,
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   276
                                            TRAPS);
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   277
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   278
  static ResourceBitMap calculate_oopmap(MemRegion region);
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   279
#endif // INCLUDE_CDS_JAVA_HEAP
52062
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   280
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   281
 public:
52062
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   282
  static bool is_heap_object_archiving_allowed() {
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   283
    CDS_JAVA_HEAP_ONLY(return (UseG1GC && UseCompressedOops && UseCompressedClassPointers);)
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   284
    NOT_CDS_JAVA_HEAP(return false;)
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   285
  }
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   286
52402
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   287
  static bool is_heap_region(int idx) {
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   288
    CDS_JAVA_HEAP_ONLY(return (idx >= MetaspaceShared::first_closed_archive_heap_region &&
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   289
                               idx <= MetaspaceShared::last_open_archive_heap_region));
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   290
    NOT_CDS_JAVA_HEAP_RETURN_(false);
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   291
  }
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   292
  static bool is_closed_archive_heap_region(int idx) {
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   293
    CDS_JAVA_HEAP_ONLY(return (idx >= MetaspaceShared::first_closed_archive_heap_region &&
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   294
                               idx <= MetaspaceShared::last_closed_archive_heap_region));
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   295
    NOT_CDS_JAVA_HEAP_RETURN_(false);
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   296
  }
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   297
  static bool is_open_archive_heap_region(int idx) {
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   298
    CDS_JAVA_HEAP_ONLY(return (idx >= MetaspaceShared::first_open_archive_heap_region &&
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   299
                               idx <= MetaspaceShared::last_open_archive_heap_region));
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   300
    NOT_CDS_JAVA_HEAP_RETURN_(false);
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   301
  }
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   302
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   303
  static void set_closed_archive_heap_region_mapped() {
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   304
    CDS_JAVA_HEAP_ONLY(_closed_archive_heap_region_mapped = true);
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   305
    NOT_CDS_JAVA_HEAP_RETURN;
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   306
  }
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   307
  static bool closed_archive_heap_region_mapped() {
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   308
    CDS_JAVA_HEAP_ONLY(return _closed_archive_heap_region_mapped);
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   309
    NOT_CDS_JAVA_HEAP_RETURN_(false);
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   310
  }
52062
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   311
  static void set_open_archive_heap_region_mapped() {
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   312
    CDS_JAVA_HEAP_ONLY(_open_archive_heap_region_mapped = true);
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   313
    NOT_CDS_JAVA_HEAP_RETURN;
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   314
  }
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   315
  static bool open_archive_heap_region_mapped() {
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   316
    CDS_JAVA_HEAP_ONLY(return _open_archive_heap_region_mapped);
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   317
    NOT_CDS_JAVA_HEAP_RETURN_(false);
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   318
  }
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   319
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   320
  static void fixup_mapped_heap_regions() NOT_CDS_JAVA_HEAP_RETURN;
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   321
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   322
  inline static bool is_archived_object(oop p) NOT_CDS_JAVA_HEAP_RETURN_(false);
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   323
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   324
  static void archive_java_heap_objects() NOT_CDS_JAVA_HEAP_RETURN;
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 52047
diff changeset
   325
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   326
  static char* read_archived_subgraph_infos(char* buffer) NOT_CDS_JAVA_HEAP_RETURN_(buffer);
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   327
  static void write_archived_subgraph_infos() NOT_CDS_JAVA_HEAP_RETURN;
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   328
  static void initialize_from_archived_subgraph(Klass* k) NOT_CDS_JAVA_HEAP_RETURN;
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   329
51491
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 51429
diff changeset
   330
  // NarrowOops stored in the CDS archive may use a different encoding scheme
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 51429
diff changeset
   331
  // than Universe::narrow_oop_{base,shift} -- see FileMapInfo::map_heap_regions_impl.
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 51429
diff changeset
   332
  // To decode them, do not use CompressedOops::decode_not_null. Use this
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 51429
diff changeset
   333
  // function instead.
51720
b7bfd64e43a6 8210523: runtime/appcds/cacheObject/DifferentHeapSizes.java crash
iklam
parents: 51701
diff changeset
   334
  inline static oop decode_from_archive(narrowOop v) NOT_CDS_JAVA_HEAP_RETURN_(NULL);
51491
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 51429
diff changeset
   335
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 51429
diff changeset
   336
  static void init_narrow_oop_decoding(address base, int shift) NOT_CDS_JAVA_HEAP_RETURN;
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 51429
diff changeset
   337
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 51429
diff changeset
   338
  static void patch_archived_heap_embedded_pointers(MemRegion mem, address  oopmap,
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 51429
diff changeset
   339
                                                    size_t oopmap_in_bits) NOT_CDS_JAVA_HEAP_RETURN;
187c84a5efe1 8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents: 51429
diff changeset
   340
52402
72d4e10305b9 8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents: 52062
diff changeset
   341
  static void init_subgraph_entry_fields(Thread* THREAD) NOT_CDS_JAVA_HEAP_RETURN;
52047
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   342
  static void write_subgraph_info_table() NOT_CDS_JAVA_HEAP_RETURN;
7bc8b456e5ac 8210388: Use hash table to store archived subgraph_info records
iklam
parents: 51720
diff changeset
   343
  static void serialize_subgraph_info_table_header(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN;
50951
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   344
};
b96466cdfc45 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
jiangli
parents:
diff changeset
   345
#endif // SHARE_VM_MEMORY_HEAPSHARED_HPP