src/hotspot/share/memory/dynamicArchive.hpp
author dcubed
Sat, 21 Sep 2019 10:13:25 -0400
changeset 58252 14c1ff687621
parent 58096 0d97bf7cf8a4
child 59070 22ee476cc664
permissions -rw-r--r--
8231323: ProblemList jdk/jfr/jcmd/TestJcmdConfigure.java Reviewed-by: ysuenaga
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
     1
/*
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
     4
 *
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
     8
 *
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    13
 * accompanied this code).
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    14
 *
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    18
 *
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    21
 * questions.
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    22
 *
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    23
 */
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    24
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    25
#ifndef SHARE_VM_MEMORY_DYNAMICARCHIVE_HPP
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    26
#define SHARE_VM_MEMORY_DYNAMICARCHIVE_HPP
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    27
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    28
#if INCLUDE_CDS
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    29
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    30
#include "classfile/compactHashtable.hpp"
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    31
#include "memory/allocation.hpp"
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    32
#include "memory/filemap.hpp"
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    33
#include "memory/memRegion.hpp"
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    34
#include "memory/virtualspace.hpp"
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    35
#include "oops/oop.hpp"
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    36
#include "utilities/exceptions.hpp"
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    37
#include "utilities/macros.hpp"
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    38
#include "utilities/resourceHash.hpp"
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    39
58096
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    40
class DynamicArchiveHeader : public FileMapHeader {
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    41
  friend class CDSOffsets;
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    42
private:
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    43
  int _base_header_crc;
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    44
  int _base_region_crc[MetaspaceShared::n_regions];
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    45
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    46
public:
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    47
  int base_header_crc() const { return _base_header_crc; }
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    48
  int base_region_crc(int i) const {
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    49
    assert(is_valid_region(i), "must be");
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    50
    return _base_region_crc[i];
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    51
  }
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    52
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    53
  void set_base_header_crc(int c) { _base_header_crc = c; }
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    54
  void set_base_region_crc(int i, int c) {
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    55
    assert(is_valid_region(i), "must be");
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    56
    _base_region_crc[i] = c;
0d97bf7cf8a4 8230586: Encapsulate fields in filemap.hpp
iklam
parents: 54927
diff changeset
    57
  }
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    58
};
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    59
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    60
class DynamicArchive : AllStatic {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    61
  static class DynamicArchiveBuilder* _builder;
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    62
  static address original_to_target_impl(address orig_obj);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    63
  static address original_to_buffer_impl(address orig_obj);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    64
  static address buffer_to_target_impl(address buff_obj);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    65
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    66
public:
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    67
  static void dump();
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    68
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    69
  // obj is a copy of a MetaspaceObj, stored in the dumping buffer.
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    70
  //
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    71
  // The return value is the runtime targeted location of this object as
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    72
  // mapped from the dynamic archive.
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    73
  template <typename T> static T buffer_to_target(T buff_obj) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    74
    return (T)buffer_to_target_impl(address(buff_obj));
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    75
  }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    76
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    77
  // obj is an original MetaspaceObj used by the JVM (e.g., a valid Symbol* in the
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    78
  // SymbolTable).
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    79
  //
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    80
  // The return value is the runtime targeted location of this object as
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    81
  // mapped from the dynamic archive.
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    82
  template <typename T> static T original_to_target(T obj) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    83
    return (T)original_to_target_impl(address(obj));
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    84
  }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    85
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    86
  // obj is an original MetaspaceObj use by the JVM (e.g., a valid Symbol* in the
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    87
  // SymbolTable).
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    88
  //
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    89
  // The return value is the location of this object in the dump time
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    90
  // buffer space
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    91
  template <typename T> static T original_to_buffer(T obj) {
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    92
    return (T)original_to_buffer_impl(address(obj));
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    93
  }
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    94
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    95
  // Delta of this object from SharedBaseAddress
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    96
  static uintx object_delta_uintx(void* buff_obj);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    97
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    98
  // Does obj point to an address inside the runtime target space of the dynamic
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
    99
  // archive?
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
   100
  static bool is_in_target_space(void *obj);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
   101
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
   102
  static address map();
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
   103
  static bool is_mapped();
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
   104
  static bool validate(FileMapInfo* dynamic_info);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
   105
  static void disable();
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
   106
private:
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
   107
  static address map_impl(FileMapInfo* mapinfo);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
   108
  static void map_failed(FileMapInfo* mapinfo);
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
   109
};
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
   110
#endif // INCLUDE_CDS
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents:
diff changeset
   111
#endif // SHARE_VM_MEMORY_DYNAMICARCHIVE_HPP