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