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