author | vlivanov |
Tue, 26 Nov 2019 16:09:21 +0300 | |
changeset 59276 | 94a84abb873b |
parent 58527 | f9cc0141574c |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
48157
diff
changeset
|
2 |
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3795
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3795
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3795
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
48157
diff
changeset
|
25 |
#ifndef SHARE_COMPILER_OOPMAP_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
48157
diff
changeset
|
26 |
#define SHARE_COMPILER_OOPMAP_HPP |
7397 | 27 |
|
28 |
#include "code/compressedStream.hpp" |
|
29 |
#include "code/vmreg.hpp" |
|
30 |
#include "memory/allocation.hpp" |
|
48157 | 31 |
#include "oops/oopsHierarchy.hpp" |
7397 | 32 |
|
1 | 33 |
// Interface for generating the frame map for compiled code. A frame map |
34 |
// describes for a specific pc whether each register and frame stack slot is: |
|
35 |
// Oop - A GC root for current frame |
|
36 |
// Dead - Dead; can be Zapped for debugging |
|
37 |
// CalleeXX - Callee saved; also describes which caller register is saved |
|
38 |
// DerivedXX - A derived oop; original oop is described. |
|
39 |
// |
|
40 |
// OopMapValue describes a single OopMap entry |
|
41 |
||
42 |
class frame; |
|
43 |
class RegisterMap; |
|
48157 | 44 |
class OopClosure; |
1 | 45 |
|
46 |
class OopMapValue: public StackObj { |
|
47 |
friend class VMStructs; |
|
48 |
private: |
|
49 |
short _value; |
|
50 |
int value() const { return _value; } |
|
51 |
void set_value(int value) { _value = value; } |
|
52 |
short _content_reg; |
|
53 |
||
54 |
public: |
|
55 |
// Constants |
|
58527
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
56 |
enum { type_bits = 2, |
1 | 57 |
register_bits = BitsPerShort - type_bits }; |
58 |
||
59 |
enum { type_shift = 0, |
|
60 |
register_shift = type_bits }; |
|
61 |
||
62 |
enum { type_mask = right_n_bits(type_bits), |
|
63 |
type_mask_in_place = type_mask << type_shift, |
|
64 |
register_mask = right_n_bits(register_bits), |
|
65 |
register_mask_in_place = register_mask << register_shift }; |
|
66 |
||
58527
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
67 |
enum oop_types { |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
68 |
oop_value, |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
69 |
narrowoop_value, |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
70 |
callee_saved_value, |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
71 |
derived_oop_value, |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
72 |
unused_value = -1 // Only used as a sentinel value |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
73 |
}; |
1 | 74 |
|
75 |
// Constructors |
|
76 |
OopMapValue () { set_value(0); set_content_reg(VMRegImpl::Bad()); } |
|
58527
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
77 |
OopMapValue (VMReg reg, oop_types t, VMReg reg2) { |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
78 |
set_reg_type(reg, t); |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
79 |
set_content_reg(reg2); |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
80 |
} |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
81 |
|
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
82 |
private: |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
83 |
void set_reg_type(VMReg p, oop_types t) { |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
84 |
set_value((p->value() << register_shift) | t); |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
85 |
assert(reg() == p, "sanity check" ); |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
86 |
assert(type() == t, "sanity check" ); |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
87 |
} |
1 | 88 |
|
58527
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
89 |
void set_content_reg(VMReg r) { |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
90 |
if (is_callee_saved()) { |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
91 |
// This can never be a stack location, so we don't need to transform it. |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
92 |
assert(r->is_reg(), "Trying to callee save a stack location"); |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
93 |
} else if (is_derived_oop()) { |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
94 |
assert (r->is_valid(), "must have a valid VMReg"); |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
95 |
} else { |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
96 |
assert (!r->is_valid(), "valid VMReg not allowed"); |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
97 |
} |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
98 |
_content_reg = r->value(); |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
99 |
} |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
100 |
|
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
101 |
public: |
1 | 102 |
// Archiving |
103 |
void write_on(CompressedWriteStream* stream) { |
|
104 |
stream->write_int(value()); |
|
105 |
if(is_callee_saved() || is_derived_oop()) { |
|
106 |
stream->write_int(content_reg()->value()); |
|
107 |
} |
|
108 |
} |
|
109 |
||
110 |
void read_from(CompressedReadStream* stream) { |
|
111 |
set_value(stream->read_int()); |
|
33589
7cbd1b2c139b
8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents:
33160
diff
changeset
|
112 |
if (is_callee_saved() || is_derived_oop()) { |
1 | 113 |
set_content_reg(VMRegImpl::as_VMReg(stream->read_int(), true)); |
114 |
} |
|
115 |
} |
|
116 |
||
117 |
// Querying |
|
118 |
bool is_oop() { return mask_bits(value(), type_mask_in_place) == oop_value; } |
|
58527
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
119 |
bool is_narrowoop() { return mask_bits(value(), type_mask_in_place) == narrowoop_value; } |
1 | 120 |
bool is_callee_saved() { return mask_bits(value(), type_mask_in_place) == callee_saved_value; } |
121 |
bool is_derived_oop() { return mask_bits(value(), type_mask_in_place) == derived_oop_value; } |
|
122 |
||
123 |
VMReg reg() const { return VMRegImpl::as_VMReg(mask_bits(value(), register_mask_in_place) >> register_shift); } |
|
124 |
oop_types type() const { return (oop_types)mask_bits(value(), type_mask_in_place); } |
|
125 |
||
126 |
static bool legal_vm_reg_name(VMReg p) { |
|
127 |
return (p->value() == (p->value() & register_mask)); |
|
128 |
} |
|
129 |
||
130 |
VMReg content_reg() const { return VMRegImpl::as_VMReg(_content_reg, true); } |
|
131 |
||
132 |
// Physical location queries |
|
133 |
bool is_register_loc() { return reg()->is_reg(); } |
|
134 |
bool is_stack_loc() { return reg()->is_stack(); } |
|
135 |
||
136 |
// Returns offset from sp. |
|
137 |
int stack_offset() { |
|
138 |
assert(is_stack_loc(), "must be stack location"); |
|
139 |
return reg()->reg2stack(); |
|
140 |
} |
|
141 |
||
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
142 |
void print_on(outputStream* st) const; |
54807 | 143 |
void print() const; |
1 | 144 |
}; |
145 |
||
146 |
||
147 |
class OopMap: public ResourceObj { |
|
148 |
friend class OopMapStream; |
|
149 |
friend class VMStructs; |
|
150 |
private: |
|
30590 | 151 |
int _pc_offset; // offset in the code that this OopMap corresponds to |
152 |
int _omv_count; // number of OopMapValues in the stream |
|
1 | 153 |
CompressedWriteStream* _write_stream; |
154 |
||
155 |
debug_only( OopMapValue::oop_types* _locs_used; int _locs_length;) |
|
156 |
||
157 |
// Accessors |
|
158 |
int omv_count() const { return _omv_count; } |
|
159 |
void set_omv_count(int value) { _omv_count = value; } |
|
160 |
void increment_count() { _omv_count++; } |
|
161 |
CompressedWriteStream* write_stream() const { return _write_stream; } |
|
162 |
void set_write_stream(CompressedWriteStream* value) { _write_stream = value; } |
|
163 |
||
164 |
private: |
|
165 |
enum DeepCopyToken { _deep_copy_token }; |
|
166 |
OopMap(DeepCopyToken, OopMap* source); // used only by deep_copy |
|
167 |
||
58527
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
168 |
void set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional); |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
169 |
|
1 | 170 |
public: |
171 |
OopMap(int frame_size, int arg_count); |
|
172 |
||
173 |
// pc-offset handling |
|
174 |
int offset() const { return _pc_offset; } |
|
175 |
void set_offset(int o) { _pc_offset = o; } |
|
30590 | 176 |
int count() const { return _omv_count; } |
177 |
int data_size() const { return write_stream()->position(); } |
|
178 |
address data() const { return write_stream()->buffer(); } |
|
1 | 179 |
|
180 |
// Check to avoid double insertion |
|
181 |
debug_only(OopMapValue::oop_types locs_used( int indx ) { return _locs_used[indx]; }) |
|
182 |
||
183 |
// Construction |
|
184 |
// frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd |
|
185 |
// slots to hold 4-byte values like ints and floats in the LP64 build. |
|
186 |
void set_oop ( VMReg local); |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
347
diff
changeset
|
187 |
void set_narrowoop(VMReg local); |
1 | 188 |
void set_callee_saved( VMReg local, VMReg caller_machine_register ); |
189 |
void set_derived_oop ( VMReg local, VMReg derived_from_local_register ); |
|
190 |
||
191 |
int heap_size() const; |
|
30590 | 192 |
void copy_data_to(address addr) const; |
1 | 193 |
OopMap* deep_copy(); |
194 |
||
195 |
bool legal_vm_reg_name(VMReg local) { |
|
196 |
return OopMapValue::legal_vm_reg_name(local); |
|
197 |
} |
|
198 |
||
199 |
// Printing |
|
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
200 |
void print_on(outputStream* st) const; |
54807 | 201 |
void print() const; |
30590 | 202 |
bool equals(const OopMap* other) const; |
1 | 203 |
}; |
204 |
||
205 |
||
206 |
class OopMapSet : public ResourceObj { |
|
207 |
friend class VMStructs; |
|
208 |
private: |
|
209 |
int _om_count; |
|
210 |
int _om_size; |
|
211 |
OopMap** _om_data; |
|
212 |
||
213 |
int om_count() const { return _om_count; } |
|
214 |
void set_om_count(int value) { _om_count = value; } |
|
215 |
void increment_count() { _om_count++; } |
|
216 |
int om_size() const { return _om_size; } |
|
217 |
void set_om_size(int value) { _om_size = value; } |
|
218 |
OopMap** om_data() const { return _om_data; } |
|
219 |
void set_om_data(OopMap** value) { _om_data = value; } |
|
220 |
void grow_om_data(); |
|
221 |
void set(int index,OopMap* value) { assert((index == 0) || ((index > 0) && (index < om_size())),"bad index"); _om_data[index] = value; } |
|
222 |
||
223 |
public: |
|
224 |
OopMapSet(); |
|
225 |
||
226 |
// returns the number of OopMaps in this OopMapSet |
|
227 |
int size() const { return _om_count; } |
|
228 |
// returns the OopMap at a given index |
|
229 |
OopMap* at(int index) const { assert((index >= 0) && (index <= om_count()),"bad index"); return _om_data[index]; } |
|
230 |
||
231 |
// Collect OopMaps. |
|
232 |
void add_gc_map(int pc, OopMap* map); |
|
233 |
||
234 |
// Returns the only oop map. Used for reconstructing |
|
235 |
// Adapter frames during deoptimization |
|
236 |
OopMap* singular_oop_map(); |
|
237 |
||
238 |
// returns OopMap in that is anchored to the pc |
|
239 |
OopMap* find_map_at_offset(int pc_offset) const; |
|
240 |
||
241 |
int heap_size() const; |
|
242 |
||
3275 | 243 |
// Methods oops_do() and all_do() filter out NULL oops and |
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
53244
diff
changeset
|
244 |
// oop == CompressedOops::base() before passing oops |
3275 | 245 |
// to closures. |
246 |
||
1 | 247 |
// Iterates through frame for a compiled method |
248 |
static void oops_do (const frame* fr, |
|
249 |
const RegisterMap* reg_map, OopClosure* f); |
|
250 |
static void update_register_map(const frame* fr, RegisterMap *reg_map); |
|
251 |
||
252 |
// Iterates through frame for a compiled method for dead ones and values, too |
|
253 |
static void all_do(const frame* fr, const RegisterMap* reg_map, |
|
254 |
OopClosure* oop_fn, |
|
255 |
void derived_oop_fn(oop* base, oop* derived), |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
347
diff
changeset
|
256 |
OopClosure* value_fn); |
1 | 257 |
|
258 |
// Printing |
|
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
198
diff
changeset
|
259 |
void print_on(outputStream* st) const; |
54807 | 260 |
void print() const; |
1 | 261 |
}; |
262 |
||
30590 | 263 |
class ImmutableOopMapBuilder; |
264 |
||
265 |
class ImmutableOopMap { |
|
266 |
friend class OopMapStream; |
|
267 |
friend class VMStructs; |
|
268 |
#ifdef ASSERT |
|
269 |
friend class ImmutableOopMapBuilder; |
|
270 |
#endif |
|
271 |
private: |
|
272 |
int _count; // contains the number of entries in this OopMap |
|
273 |
||
274 |
address data_addr() const { return (address) this + sizeof(ImmutableOopMap); } |
|
275 |
public: |
|
276 |
ImmutableOopMap(const OopMap* oopmap); |
|
277 |
||
278 |
int count() const { return _count; } |
|
30774 | 279 |
#ifdef ASSERT |
280 |
int nr_of_bytes() const; // this is an expensive operation, only used in debug builds |
|
281 |
#endif |
|
30590 | 282 |
|
283 |
// Printing |
|
284 |
void print_on(outputStream* st) const; |
|
54807 | 285 |
void print() const; |
30590 | 286 |
}; |
287 |
||
288 |
class ImmutableOopMapSet; |
|
289 |
class ImmutableOopMap; |
|
290 |
class OopMapSet; |
|
291 |
||
292 |
class ImmutableOopMapPair { |
|
293 |
friend class VMStructs; |
|
294 |
private: |
|
295 |
int _pc_offset; // program counter offset from the beginning of the method |
|
296 |
int _oopmap_offset; // offset in the data in the ImmutableOopMapSet where the ImmutableOopMap is located |
|
297 |
public: |
|
298 |
ImmutableOopMapPair(int pc_offset, int oopmap_offset) : _pc_offset(pc_offset), _oopmap_offset(oopmap_offset) { |
|
299 |
assert(pc_offset >= 0 && oopmap_offset >= 0, "check"); |
|
300 |
} |
|
301 |
const ImmutableOopMap* get_from(const ImmutableOopMapSet* set) const; |
|
302 |
||
303 |
int pc_offset() const { return _pc_offset; } |
|
304 |
int oopmap_offset() const { return _oopmap_offset; } |
|
305 |
}; |
|
306 |
||
307 |
class ImmutableOopMapSet { |
|
308 |
friend class VMStructs; |
|
309 |
private: |
|
310 |
int _count; // nr of ImmutableOopMapPairs in the Set |
|
311 |
int _size; // nr of bytes including ImmutableOopMapSet itself |
|
312 |
||
313 |
address data() const { return (address) this + sizeof(*this) + sizeof(ImmutableOopMapPair) * _count; } |
|
314 |
||
315 |
public: |
|
316 |
ImmutableOopMapSet(const OopMapSet* oopmap_set, int size) : _count(oopmap_set->size()), _size(size) {} |
|
317 |
||
318 |
ImmutableOopMap* oopmap_at_offset(int offset) const { |
|
319 |
assert(offset >= 0 && offset < _size, "must be within boundaries"); |
|
320 |
address addr = data() + offset; |
|
321 |
return (ImmutableOopMap*) addr; |
|
322 |
} |
|
323 |
||
324 |
ImmutableOopMapPair* get_pairs() const { return (ImmutableOopMapPair*) ((address) this + sizeof(*this)); } |
|
325 |
||
326 |
static ImmutableOopMapSet* build_from(const OopMapSet* oopmap_set); |
|
327 |
||
328 |
const ImmutableOopMap* find_map_at_offset(int pc_offset) const; |
|
329 |
||
330 |
const ImmutableOopMapPair* pair_at(int index) const { assert(index >= 0 && index < _count, "check"); return &get_pairs()[index]; } |
|
331 |
||
332 |
int count() const { return _count; } |
|
30628
3c15b4a3bf4d
8079797: assert(index >= 0 && index < _count) failed: check
rbackman
parents:
30590
diff
changeset
|
333 |
int nr_of_bytes() const { return _size; } |
30590 | 334 |
|
335 |
void print_on(outputStream* st) const; |
|
54807 | 336 |
void print() const; |
30590 | 337 |
}; |
1 | 338 |
|
339 |
class OopMapStream : public StackObj { |
|
340 |
private: |
|
341 |
CompressedReadStream* _stream; |
|
342 |
int _size; |
|
343 |
int _position; |
|
344 |
bool _valid_omv; |
|
345 |
OopMapValue _omv; |
|
346 |
void find_next(); |
|
347 |
||
348 |
public: |
|
58527
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
349 |
OopMapStream(OopMap* oop_map); |
f9cc0141574c
8231586: enlarge encoding space for OopMapValue offsets
never
parents:
54916
diff
changeset
|
350 |
OopMapStream(const ImmutableOopMap* oop_map); |
1 | 351 |
bool is_done() { if(!_valid_omv) { find_next(); } return !_valid_omv; } |
352 |
void next() { find_next(); } |
|
353 |
OopMapValue current() { return _omv; } |
|
30774 | 354 |
#ifdef ASSERT |
355 |
int stream_position() const { return _stream->position(); } |
|
356 |
#endif |
|
1 | 357 |
}; |
358 |
||
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
359 |
class ImmutableOopMapBuilder { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
360 |
private: |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
361 |
class Mapping; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
362 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
363 |
private: |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
364 |
const OopMapSet* _set; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
365 |
const OopMap* _empty; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
366 |
const OopMap* _last; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
367 |
int _empty_offset; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
368 |
int _last_offset; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
369 |
int _offset; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
370 |
int _required; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
371 |
Mapping* _mapping; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
372 |
ImmutableOopMapSet* _new_set; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
373 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
374 |
/* Used for bookkeeping when building ImmutableOopMaps */ |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
375 |
class Mapping : public ResourceObj { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
376 |
public: |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
377 |
enum kind_t { OOPMAP_UNKNOWN = 0, OOPMAP_NEW = 1, OOPMAP_EMPTY = 2, OOPMAP_DUPLICATE = 3 }; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
378 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
379 |
kind_t _kind; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
380 |
int _offset; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
381 |
int _size; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
382 |
const OopMap* _map; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
383 |
const OopMap* _other; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
384 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
385 |
Mapping() : _kind(OOPMAP_UNKNOWN), _offset(-1), _size(-1), _map(NULL) {} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
386 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
387 |
void set(kind_t kind, int offset, int size, const OopMap* map = 0, const OopMap* other = 0) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
388 |
_kind = kind; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
389 |
_offset = offset; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
390 |
_size = size; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
391 |
_map = map; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
392 |
_other = other; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
393 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
394 |
}; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
395 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
396 |
public: |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
397 |
ImmutableOopMapBuilder(const OopMapSet* set); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
398 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
399 |
int heap_size(); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
400 |
ImmutableOopMapSet* build(); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
401 |
ImmutableOopMapSet* generate_into(address buffer); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
402 |
private: |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
403 |
bool is_empty(const OopMap* map) const { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
404 |
return map->count() == 0; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
405 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
406 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
407 |
bool is_last_duplicate(const OopMap* map) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
408 |
if (_last != NULL && _last->count() > 0 && _last->equals(map)) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
409 |
return true; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
410 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
411 |
return false; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
412 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
413 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
414 |
#ifdef ASSERT |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
415 |
void verify(address buffer, int size, const ImmutableOopMapSet* set); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
416 |
#endif |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
417 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
418 |
bool has_empty() const { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
419 |
return _empty_offset != -1; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
420 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
421 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
422 |
int size_for(const OopMap* map) const; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
423 |
void fill_pair(ImmutableOopMapPair* pair, const OopMap* map, int offset, const ImmutableOopMapSet* set); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
424 |
int fill_map(ImmutableOopMapPair* pair, const OopMap* map, int offset, const ImmutableOopMapSet* set); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
425 |
void fill(ImmutableOopMapSet* set, int size); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
426 |
}; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
33063
diff
changeset
|
427 |
|
1 | 428 |
|
429 |
// Derived pointer support. This table keeps track of all derived points on a |
|
430 |
// stack. It is cleared before each scavenge/GC. During the traversal of all |
|
431 |
// oops, it is filled in with references to all locations that contains a |
|
432 |
// derived oop (assumed to be very few). When the GC is complete, the derived |
|
433 |
// pointers are updated based on their base pointers new value and an offset. |
|
47799 | 434 |
#if COMPILER2_OR_JVMCI |
1 | 435 |
class DerivedPointerTable : public AllStatic { |
436 |
friend class VMStructs; |
|
437 |
private: |
|
54916
7136c9ac56a7
8160539: Stack frame scanning acquires DerivedPointerTableGC_lock mutex
kbarrett
parents:
54807
diff
changeset
|
438 |
class Entry; |
7136c9ac56a7
8160539: Stack frame scanning acquires DerivedPointerTableGC_lock mutex
kbarrett
parents:
54807
diff
changeset
|
439 |
static bool _active; // do not record pointers for verify pass etc. |
7136c9ac56a7
8160539: Stack frame scanning acquires DerivedPointerTableGC_lock mutex
kbarrett
parents:
54807
diff
changeset
|
440 |
|
1 | 441 |
public: |
442 |
static void clear(); // Called before scavenge/GC |
|
443 |
static void add(oop *derived, oop *base); // Called during scavenge/GC |
|
444 |
static void update_pointers(); // Called after scavenge/GC |
|
54916
7136c9ac56a7
8160539: Stack frame scanning acquires DerivedPointerTableGC_lock mutex
kbarrett
parents:
54807
diff
changeset
|
445 |
static bool is_empty(); |
1 | 446 |
static bool is_active() { return _active; } |
447 |
static void set_active(bool value) { _active = value; } |
|
448 |
}; |
|
449 |
||
450 |
// A utility class to temporarily "deactivate" the DerivedPointerTable. |
|
451 |
// (Note: clients are responsible for any MT-safety issues) |
|
452 |
class DerivedPointerTableDeactivate: public StackObj { |
|
453 |
private: |
|
454 |
bool _active; |
|
455 |
public: |
|
456 |
DerivedPointerTableDeactivate() { |
|
457 |
_active = DerivedPointerTable::is_active(); |
|
458 |
if (_active) { |
|
459 |
DerivedPointerTable::set_active(false); |
|
460 |
} |
|
461 |
} |
|
462 |
||
463 |
~DerivedPointerTableDeactivate() { |
|
464 |
assert(!DerivedPointerTable::is_active(), |
|
465 |
"Inconsistency: not MT-safe"); |
|
466 |
if (_active) { |
|
467 |
DerivedPointerTable::set_active(true); |
|
468 |
} |
|
469 |
} |
|
470 |
}; |
|
47799 | 471 |
#endif // COMPILER2_OR_JVMCI |
7397 | 472 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
48157
diff
changeset
|
473 |
#endif // SHARE_COMPILER_OOPMAP_HPP |