src/hotspot/share/include/cds.h
author iklam
Wed, 13 Nov 2019 16:36:54 -0800
changeset 59070 22ee476cc664
parent 58096 0d97bf7cf8a4
permissions -rw-r--r--
8231610: Relocate the CDS archive if it cannot be mapped to the requested address Reviewed-by: jiangli, coleenp, ccheung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51477
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
     1
/*
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 51491
diff changeset
     2
 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
51477
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
     4
 *
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
     8
 *
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    13
 * accompanied this code).
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    14
 *
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    18
 *
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    21
 * questions.
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    22
 *
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    23
 */
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    24
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    25
#ifndef SHARE_INCLUDE_CDS_H
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    26
#define SHARE_INCLUDE_CDS_H
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    27
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    28
// This file declares the CDS data structures that are used by the HotSpot Serviceability Agent
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    29
// (see C sources inside src/jdk.hotspot.agent).
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    30
//
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    31
// We should use only standard C types. Do not use custom types such as bool, intx,
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    32
// etc, to avoid introducing unnecessary dependencies to other HotSpot type declarations.
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    33
//
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    34
// Also, this is a C header file. Do not use C++ here.
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    35
59070
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    36
#define NUM_CDS_REGIONS 9 // this must be the same as MetaspaceShared::n_regions
51477
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    37
#define CDS_ARCHIVE_MAGIC 0xf00baba2
54927
1512d88b24c6 8207812: Implement Dynamic CDS Archive
ccheung
parents: 51491
diff changeset
    38
#define CDS_DYNAMIC_ARCHIVE_MAGIC 0xf00baba8
59070
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    39
#define CURRENT_CDS_ARCHIVE_VERSION 9
51477
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    40
#define INVALID_CDS_ARCHIVE_VERSION -1
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    41
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    42
struct CDSFileMapRegion {
59070
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    43
  int     _crc;               // CRC checksum of this region.
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    44
  int     _read_only;         // read only region?
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    45
  int     _allow_exec;        // executable code in this region?
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    46
  int     _is_heap_region;    // Used by SA and debug build.
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    47
  int     _is_bitmap_region;  // Relocation bitmap for RO/RW/MC/MD regions (used by SA and debug build).
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    48
  int     _mapped_from_file;  // Is this region mapped from a file?
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    49
                              // If false, this region was initialized using os::read().
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    50
  size_t  _file_offset;       // Data for this region starts at this offset in the archive file.
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    51
  size_t  _mapping_offset;    // This region should be mapped at this offset from the base address
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    52
                              // - for non-heap regions, the base address is SharedBaseAddress
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    53
                              // - for heap regions, the base address is the compressed oop encoding base
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    54
  size_t  _used;              // Number of bytes actually used by this region (excluding padding bytes added
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    55
                              // for alignment purposed.
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    56
  size_t  _oopmap_offset;     // Bitmap for relocating embedded oops (offset from SharedBaseAddress).
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    57
  size_t  _oopmap_size_in_bits;
22ee476cc664 8231610: Relocate the CDS archive if it cannot be mapped to the requested address
iklam
parents: 58096
diff changeset
    58
  char*   _mapped_base;       // Actually mapped address (NULL if this region is not mapped).
51477
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    59
};
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    60
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    61
struct CDSFileMapHeaderBase {
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    62
  unsigned int _magic;           // identify file type
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    63
  int          _crc;             // header crc checksum
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    64
  int          _version;         // must be CURRENT_CDS_ARCHIVE_VERSION
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    65
  struct CDSFileMapRegion _space[NUM_CDS_REGIONS];
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    66
};
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    67
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    68
typedef struct CDSFileMapHeaderBase CDSFileMapHeaderBase;
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    69
e77d7687c831 8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
diff changeset
    70
#endif // SHARE_INCLUDE_CDS_H