author | ccheung |
Fri, 17 May 2019 08:29:55 -0700 | |
changeset 54927 | 1512d88b24c6 |
parent 53884 | 1a7b57d02107 |
child 55251 | 92eec0732eed |
child 58678 | 9cf78a70fa4f |
permissions | -rw-r--r-- |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52562
diff
changeset
|
2 |
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
4 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
8 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
13 |
* accompanied this code). |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
14 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
18 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
21 |
* questions. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
22 |
* |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
23 |
*/ |
30578 | 24 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52562
diff
changeset
|
25 |
#ifndef SHARE_MEMORY_METASPACESHARED_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52562
diff
changeset
|
26 |
#define SHARE_MEMORY_METASPACESHARED_HPP |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
27 |
|
28363
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
28023
diff
changeset
|
28 |
#include "classfile/compactHashtable.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
29 |
#include "memory/allocation.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
30 |
#include "memory/memRegion.hpp" |
30291
54cdc5c1a9cb
8068352: Move virtualspace.* out of src/share/vm/runtime to memory directory
coleenp
parents:
28363
diff
changeset
|
31 |
#include "memory/virtualspace.hpp" |
49480
d7df2dd501ce
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents:
49364
diff
changeset
|
32 |
#include "oops/oop.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
33 |
#include "utilities/exceptions.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
34 |
#include "utilities/macros.hpp" |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
35 |
#include "utilities/resourceHash.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
36 |
|
34242
e530decd7c63
8138983: Runtime: implement ranges for Shared*** flags
gziemski
parents:
31345
diff
changeset
|
37 |
#define MAX_SHARED_DELTA (0x7FFFFFFF) |
26304
a28e6335ce60
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
26135
diff
changeset
|
38 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
39 |
class FileMapInfo; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
40 |
|
49364
601146c66cad
8173070: Remove ValueObj class for allocation subclassing for runtime code
coleenp
parents:
49329
diff
changeset
|
41 |
class MetaspaceSharedStats { |
28363
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
28023
diff
changeset
|
42 |
public: |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
28023
diff
changeset
|
43 |
MetaspaceSharedStats() { |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
28023
diff
changeset
|
44 |
memset(this, 0, sizeof(*this)); |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
28023
diff
changeset
|
45 |
} |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
28023
diff
changeset
|
46 |
CompactHashtableStats symbol; |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30579
diff
changeset
|
47 |
CompactHashtableStats string; |
28363
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
28023
diff
changeset
|
48 |
}; |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
28023
diff
changeset
|
49 |
|
54927 | 50 |
#if INCLUDE_CDS |
51 |
class DumpRegion { |
|
52 |
private: |
|
53 |
const char* _name; |
|
54 |
char* _base; |
|
55 |
char* _top; |
|
56 |
char* _end; |
|
57 |
bool _is_packed; |
|
58 |
||
59 |
public: |
|
60 |
DumpRegion(const char* name) : _name(name), _base(NULL), _top(NULL), _end(NULL), _is_packed(false) {} |
|
61 |
||
62 |
char* expand_top_to(char* newtop); |
|
63 |
char* allocate(size_t num_bytes, size_t alignment=BytesPerWord); |
|
64 |
||
65 |
void append_intptr_t(intptr_t n) { |
|
66 |
assert(is_aligned(_top, sizeof(intptr_t)), "bad alignment"); |
|
67 |
intptr_t *p = (intptr_t*)_top; |
|
68 |
char* newtop = _top + sizeof(intptr_t); |
|
69 |
expand_top_to(newtop); |
|
70 |
*p = n; |
|
71 |
} |
|
72 |
||
73 |
char* base() const { return _base; } |
|
74 |
char* top() const { return _top; } |
|
75 |
char* end() const { return _end; } |
|
76 |
size_t reserved() const { return _end - _base; } |
|
77 |
size_t used() const { return _top - _base; } |
|
78 |
bool is_packed() const { return _is_packed; } |
|
79 |
bool is_allocatable() const { |
|
80 |
return !is_packed() && _base != NULL; |
|
81 |
} |
|
82 |
||
83 |
void print(size_t total_bytes) const; |
|
84 |
void print_out_of_space_msg(const char* failing_region, size_t needed_bytes); |
|
85 |
||
86 |
void init(const ReservedSpace* rs, char* base) { |
|
87 |
if (base == NULL) { |
|
88 |
base = rs->base(); |
|
89 |
} |
|
90 |
assert(rs->contains(base), "must be"); |
|
91 |
_base = _top = base; |
|
92 |
_end = rs->end(); |
|
93 |
} |
|
94 |
void init(char* b, char* t, char* e) { |
|
95 |
_base = b; |
|
96 |
_top = t; |
|
97 |
_end = e; |
|
98 |
} |
|
99 |
||
100 |
void pack(DumpRegion* next = NULL); |
|
101 |
||
102 |
bool contains(char* p) { |
|
103 |
return base() <= p && p < top(); |
|
104 |
} |
|
105 |
}; |
|
106 |
||
107 |
// Closure for serializing initialization data out to a data area to be |
|
108 |
// written to the shared file. |
|
109 |
||
110 |
class WriteClosure : public SerializeClosure { |
|
111 |
private: |
|
112 |
DumpRegion* _dump_region; |
|
113 |
||
114 |
public: |
|
115 |
WriteClosure(DumpRegion* r) { |
|
116 |
_dump_region = r; |
|
117 |
} |
|
118 |
||
119 |
void do_ptr(void** p) { |
|
120 |
_dump_region->append_intptr_t((intptr_t)*p); |
|
121 |
} |
|
122 |
||
123 |
void do_u4(u4* p) { |
|
124 |
void* ptr = (void*)(uintx(*p)); |
|
125 |
do_ptr(&ptr); |
|
126 |
} |
|
127 |
||
128 |
void do_tag(int tag) { |
|
129 |
_dump_region->append_intptr_t((intptr_t)tag); |
|
130 |
} |
|
131 |
||
132 |
void do_oop(oop* o); |
|
133 |
||
134 |
void do_region(u_char* start, size_t size); |
|
135 |
||
136 |
bool reading() const { return false; } |
|
137 |
}; |
|
138 |
||
139 |
// Closure for serializing initialization data in from a data area |
|
140 |
// (ptr_array) read from the shared file. |
|
141 |
||
142 |
class ReadClosure : public SerializeClosure { |
|
143 |
private: |
|
144 |
intptr_t** _ptr_array; |
|
145 |
||
146 |
inline intptr_t nextPtr() { |
|
147 |
return *(*_ptr_array)++; |
|
148 |
} |
|
149 |
||
150 |
public: |
|
151 |
ReadClosure(intptr_t** ptr_array) { _ptr_array = ptr_array; } |
|
152 |
||
153 |
void do_ptr(void** p); |
|
154 |
||
155 |
void do_u4(u4* p); |
|
156 |
||
157 |
void do_tag(int tag); |
|
158 |
||
159 |
void do_oop(oop *p); |
|
160 |
||
161 |
void do_region(u_char* start, size_t size); |
|
162 |
||
163 |
bool reading() const { return true; } |
|
164 |
}; |
|
165 |
||
166 |
#endif |
|
167 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
168 |
// Class Data Sharing Support |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
169 |
class MetaspaceShared : AllStatic { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
170 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
171 |
// CDS support |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
172 |
static ReservedSpace _shared_rs; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
173 |
static VirtualSpace _shared_vs; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
174 |
static int _max_alignment; |
28363
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
28023
diff
changeset
|
175 |
static MetaspaceSharedStats _stats; |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
13975
diff
changeset
|
176 |
static bool _has_error_classes; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
13975
diff
changeset
|
177 |
static bool _archive_loading_failed; |
39714 | 178 |
static bool _remapped_readwrite; |
37439
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
36508
diff
changeset
|
179 |
static address _cds_i2i_entry_code_buffers; |
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
36508
diff
changeset
|
180 |
static size_t _cds_i2i_entry_code_buffers_size; |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
181 |
static size_t _core_spaces_size; |
54927 | 182 |
static void* _shared_metaspace_static_top; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
183 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
184 |
enum { |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
185 |
// core archive spaces |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
186 |
mc = 0, // miscellaneous code for method trampolines |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
187 |
rw = 1, // read-write shared space in the heap |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
188 |
ro = 2, // read-only shared space in the heap |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
189 |
md = 3, // miscellaneous data for initializing tables, etc. |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
190 |
num_core_spaces = 4, // number of non-string regions |
53884
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
53547
diff
changeset
|
191 |
num_non_heap_spaces = 4, |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
192 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
193 |
// mapped java heap regions |
53884
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
53547
diff
changeset
|
194 |
first_closed_archive_heap_region = md + 1, |
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52314
diff
changeset
|
195 |
max_closed_archive_heap_region = 2, |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52314
diff
changeset
|
196 |
last_closed_archive_heap_region = first_closed_archive_heap_region + max_closed_archive_heap_region - 1, |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52314
diff
changeset
|
197 |
first_open_archive_heap_region = last_closed_archive_heap_region + 1, |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
198 |
max_open_archive_heap_region = 2, |
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52314
diff
changeset
|
199 |
last_open_archive_heap_region = first_open_archive_heap_region + max_open_archive_heap_region - 1, |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
200 |
|
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52314
diff
changeset
|
201 |
last_valid_region = last_open_archive_heap_region, |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
202 |
n_regions = last_valid_region + 1 // total number of regions |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
203 |
}; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
204 |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
13975
diff
changeset
|
205 |
static void prepare_for_dumping() NOT_CDS_RETURN; |
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
206 |
static void preload_and_dump(TRAPS) NOT_CDS_RETURN; |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
207 |
static int preload_classes(const char * class_list_path, |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
208 |
TRAPS) NOT_CDS_RETURN_(0); |
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
209 |
|
52062
8dbf1a13af49
8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents:
51796
diff
changeset
|
210 |
static GrowableArray<Klass*>* collected_klasses(); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
211 |
|
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
212 |
static ReservedSpace* shared_rs() { |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
213 |
CDS_ONLY(return &_shared_rs); |
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
214 |
NOT_CDS(return NULL); |
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
215 |
} |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
216 |
static void commit_shared_space_to(char* newtop) NOT_CDS_RETURN; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
217 |
static size_t core_spaces_size() { |
52562
3a9384c12260
8213713: Minor issues during MetaspaceShared::initialize_runtime_shared_and_meta_spaces
jiangli
parents:
52514
diff
changeset
|
218 |
assert(DumpSharedSpaces || UseSharedSpaces, "sanity"); |
3a9384c12260
8213713: Minor issues during MetaspaceShared::initialize_runtime_shared_and_meta_spaces
jiangli
parents:
52514
diff
changeset
|
219 |
assert(_core_spaces_size != 0, "sanity"); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
220 |
return _core_spaces_size; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
221 |
} |
47599
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47216
diff
changeset
|
222 |
static void initialize_dumptime_shared_and_meta_spaces() NOT_CDS_RETURN; |
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47216
diff
changeset
|
223 |
static void initialize_runtime_shared_and_meta_spaces() NOT_CDS_RETURN; |
54927 | 224 |
static char* initialize_dynamic_runtime_shared_spaces( |
225 |
char* static_start, char* static_end) NOT_CDS_RETURN_(NULL); |
|
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49480
diff
changeset
|
226 |
static void post_initialize(TRAPS) NOT_CDS_RETURN; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
227 |
|
54927 | 228 |
// Delta of this object from SharedBaseAddress |
229 |
static uintx object_delta_uintx(void* obj); |
|
52514
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
52402
diff
changeset
|
230 |
|
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
52402
diff
changeset
|
231 |
static u4 object_delta_u4(void* obj) { |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
52402
diff
changeset
|
232 |
// offset is guaranteed to be less than MAX_SHARED_DELTA in DumpRegion::expand_top_to() |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
52402
diff
changeset
|
233 |
uintx deltax = object_delta_uintx(obj); |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
52402
diff
changeset
|
234 |
guarantee(deltax <= MAX_SHARED_DELTA, "must be 32-bit offset"); |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
52402
diff
changeset
|
235 |
return (u4)deltax; |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
236 |
} |
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
237 |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
13975
diff
changeset
|
238 |
static void set_archive_loading_failed() { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
13975
diff
changeset
|
239 |
_archive_loading_failed = true; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
13975
diff
changeset
|
240 |
} |
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
241 |
static bool map_shared_spaces(FileMapInfo* mapinfo) NOT_CDS_RETURN_(false); |
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
242 |
static void initialize_shared_spaces() NOT_CDS_RETURN; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
243 |
|
48794
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47599
diff
changeset
|
244 |
// Return true if given address is in the shared metaspace regions (i.e., excluding any |
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47599
diff
changeset
|
245 |
// mapped shared heap regions.) |
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47599
diff
changeset
|
246 |
static bool is_in_shared_metaspace(const void* p) { |
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47599
diff
changeset
|
247 |
// If no shared metaspace regions are mapped, MetaspceObj::_shared_metaspace_{base,top} will |
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47599
diff
changeset
|
248 |
// both be NULL and all values of p will be rejected quickly. |
52314
e53af5fa0dae
8212205: VM asserts after CDS archive has been unmapped
iklam
parents:
52062
diff
changeset
|
249 |
return (p < MetaspaceObj::shared_metaspace_top() && p >= MetaspaceObj::shared_metaspace_base()); |
48794
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47599
diff
changeset
|
250 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
251 |
|
54927 | 252 |
static address shared_metaspace_top() { |
253 |
return (address)MetaspaceObj::shared_metaspace_top(); |
|
254 |
} |
|
255 |
||
256 |
static void set_shared_metaspace_range(void* base, void* top) NOT_CDS_RETURN; |
|
257 |
||
37439
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
36508
diff
changeset
|
258 |
// Return true if given address is in the shared region corresponding to the idx |
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
36508
diff
changeset
|
259 |
static bool is_in_shared_region(const void* p, int idx) NOT_CDS_RETURN_(false); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
260 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
261 |
static bool is_in_trampoline_frame(address addr) NOT_CDS_RETURN_(false); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
30579
diff
changeset
|
262 |
|
54927 | 263 |
static bool is_shared_dynamic(void* p) NOT_CDS_RETURN_(false); |
264 |
||
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
265 |
static void allocate_cpp_vtable_clones(); |
46324
8764956ec928
8005165: Remove CPU-dependent code in self-patching vtables
iklam
parents:
41182
diff
changeset
|
266 |
static intptr_t* clone_cpp_vtables(intptr_t* p); |
8764956ec928
8005165: Remove CPU-dependent code in self-patching vtables
iklam
parents:
41182
diff
changeset
|
267 |
static void zero_cpp_vtable_clones_for_writing(); |
8764956ec928
8005165: Remove CPU-dependent code in self-patching vtables
iklam
parents:
41182
diff
changeset
|
268 |
static void patch_cpp_vtable_pointers(); |
54927 | 269 |
static void serialize_cloned_cpp_vtptrs(SerializeClosure* sc); |
270 |
||
46718
1fd6f7bc17c9
8183038: Minimal vm slowdebug build fails with undefined reference to MetaspaceShared::is_valid_shared_method
iklam
parents:
46600
diff
changeset
|
271 |
static bool is_valid_shared_method(const Method* m) NOT_CDS_RETURN_(false); |
49329 | 272 |
static void serialize(SerializeClosure* sc) NOT_CDS_RETURN; |
46324
8764956ec928
8005165: Remove CPU-dependent code in self-patching vtables
iklam
parents:
41182
diff
changeset
|
273 |
|
28363
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
28023
diff
changeset
|
274 |
static MetaspaceSharedStats* stats() { |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
28023
diff
changeset
|
275 |
return &_stats; |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
28023
diff
changeset
|
276 |
} |
047115468f16
8059510: Compact symbol table layout inside shared archive.
jiangli
parents:
28023
diff
changeset
|
277 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
278 |
static void report_out_of_space(const char* name, size_t needed_bytes); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
279 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
280 |
// JVM/TI RedefineClasses() support: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
281 |
// Remap the shared readonly space to shared readwrite, private if |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
282 |
// sharing is enabled. Simply returns true if sharing is not enabled |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
283 |
// or if the remapping has already been done by a prior call. |
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
284 |
static bool remap_shared_readonly_as_readwrite() NOT_CDS_RETURN_(true); |
39714 | 285 |
static bool remapped_readwrite() { |
286 |
CDS_ONLY(return _remapped_readwrite); |
|
287 |
NOT_CDS(return false); |
|
288 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
289 |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
13975
diff
changeset
|
290 |
static bool try_link_class(InstanceKlass* ik, TRAPS); |
46464
6432a858a220
8180325: Use ClassLoaderData::classes_do for CDS classes
coleenp
parents:
46427
diff
changeset
|
291 |
static void link_and_cleanup_shared_classes(TRAPS); |
26304
a28e6335ce60
8048150: Allow easy configurations for large CDS archives
ccheung
parents:
26135
diff
changeset
|
292 |
|
54927 | 293 |
#if INCLUDE_CDS |
294 |
static ReservedSpace* reserve_shared_rs(size_t size, size_t alignment, |
|
295 |
bool large, char* requested_address); |
|
296 |
static void init_shared_dump_space(DumpRegion* first_space, address first_space_bottom = NULL); |
|
297 |
static DumpRegion* misc_code_dump_space(); |
|
298 |
static DumpRegion* read_write_dump_space(); |
|
299 |
static DumpRegion* read_only_dump_space(); |
|
300 |
static DumpRegion* optional_data_dump_space(); |
|
301 |
static void pack_dump_space(DumpRegion* current, DumpRegion* next, |
|
302 |
ReservedSpace* rs); |
|
303 |
||
304 |
static void rewrite_nofast_bytecodes_and_calculate_fingerprints(InstanceKlass* ik); |
|
305 |
#endif |
|
306 |
||
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
307 |
// Allocate a block of memory from the "mc", "ro", or "rw" regions. |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
308 |
static char* misc_code_space_alloc(size_t num_bytes); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
309 |
static char* read_only_space_alloc(size_t num_bytes); |
34257
4be3504cc03b
8140802: Clean up and refactor of class loading code for CDS
iklam
parents:
31345
diff
changeset
|
310 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
311 |
template <typename T> |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
312 |
static Array<T>* new_ro_array(int length) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
313 |
#if INCLUDE_CDS |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
314 |
size_t byte_size = Array<T>::byte_sizeof(length, sizeof(T)); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
315 |
Array<T>* array = (Array<T>*)read_only_space_alloc(byte_size); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
316 |
array->initialize(length); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
317 |
return array; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
318 |
#else |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
319 |
return NULL; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
320 |
#endif |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
321 |
} |
35231 | 322 |
|
54927 | 323 |
template <typename T> |
324 |
static size_t ro_array_bytesize(int length) { |
|
325 |
size_t byte_size = Array<T>::byte_sizeof(length, sizeof(T)); |
|
326 |
return align_up(byte_size, BytesPerWord); |
|
327 |
} |
|
328 |
||
37439
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
36508
diff
changeset
|
329 |
static address cds_i2i_entry_code_buffers(size_t total_size); |
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
36508
diff
changeset
|
330 |
|
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
36508
diff
changeset
|
331 |
static address cds_i2i_entry_code_buffers() { |
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
36508
diff
changeset
|
332 |
return _cds_i2i_entry_code_buffers; |
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
36508
diff
changeset
|
333 |
} |
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
36508
diff
changeset
|
334 |
static size_t cds_i2i_entry_code_buffers_size() { |
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
36508
diff
changeset
|
335 |
return _cds_i2i_entry_code_buffers_size; |
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
36508
diff
changeset
|
336 |
} |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46718
diff
changeset
|
337 |
static void relocate_klass_ptr(oop o); |
49329 | 338 |
|
339 |
static Klass* get_relocated_klass(Klass *k); |
|
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49480
diff
changeset
|
340 |
|
54927 | 341 |
static intptr_t* fix_cpp_vtable_for_dynamic_archive(MetaspaceObj::Type msotype, address obj); |
342 |
||
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49480
diff
changeset
|
343 |
private: |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49480
diff
changeset
|
344 |
static void read_extra_data(const char* filename, TRAPS) NOT_CDS_RETURN; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
345 |
}; |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52562
diff
changeset
|
346 |
#endif // SHARE_MEMORY_METASPACESHARED_HPP |