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