Mercurial > hg > graal-jvmci-8
annotate src/share/vm/compiler/oopMap.hpp @ 24234:ea6f94ab283b default tip
Added tag jvmci-0.36 for changeset 8128b98d4736
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Mon, 18 Sep 2017 18:49:45 +0200 |
parents | 52b62eee9e3d |
children |
rev | line source |
---|---|
0 | 1 /* |
1972 | 2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
948
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
948
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
948
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 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 | |
0 | 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 // Value - Live non-oop, non-float value: int, either half of double | |
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; | |
46 | |
47 class OopMapValue: public StackObj { | |
48 friend class VMStructs; | |
49 private: | |
50 short _value; | |
51 int value() const { return _value; } | |
52 void set_value(int value) { _value = value; } | |
53 short _content_reg; | |
54 | |
24129
52b62eee9e3d
Add backward compatible definition to vmStructs for OopMapValue::value_value
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
23974
diff
changeset
|
55 enum { |
52b62eee9e3d
Add backward compatible definition to vmStructs for OopMapValue::value_value
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
23974
diff
changeset
|
56 value_value = 0 /* for compatibility with serviceability agent */ |
52b62eee9e3d
Add backward compatible definition to vmStructs for OopMapValue::value_value
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
23974
diff
changeset
|
57 }; |
52b62eee9e3d
Add backward compatible definition to vmStructs for OopMapValue::value_value
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
23974
diff
changeset
|
58 |
0 | 59 public: |
60 // Constants | |
14988
82ff6c8c8f6e
Increase maximum allocatable spill area by factor of 2.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8151
diff
changeset
|
61 enum { type_bits = 4, |
0 | 62 register_bits = BitsPerShort - type_bits }; |
63 | |
64 enum { type_shift = 0, | |
65 register_shift = type_bits }; | |
66 | |
67 enum { type_mask = right_n_bits(type_bits), | |
68 type_mask_in_place = type_mask << type_shift, | |
69 register_mask = right_n_bits(register_bits), | |
70 register_mask_in_place = register_mask << register_shift }; | |
71 | |
72 enum oop_types { // must fit in type_bits | |
73 unused_value =0, // powers of 2, for masking OopMapStream | |
74 oop_value = 1, | |
14988
82ff6c8c8f6e
Increase maximum allocatable spill area by factor of 2.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8151
diff
changeset
|
75 narrowoop_value = 2, |
82ff6c8c8f6e
Increase maximum allocatable spill area by factor of 2.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8151
diff
changeset
|
76 callee_saved_value = 4, |
82ff6c8c8f6e
Increase maximum allocatable spill area by factor of 2.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8151
diff
changeset
|
77 derived_oop_value= 8 }; |
0 | 78 |
79 // Constructors | |
80 OopMapValue () { set_value(0); set_content_reg(VMRegImpl::Bad()); } | |
23822
626f594dffa6
8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
csahu
parents:
1972
diff
changeset
|
81 OopMapValue (VMReg reg, oop_types t) { set_reg_type(reg, t); set_content_reg(VMRegImpl::Bad()); } |
626f594dffa6
8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
csahu
parents:
1972
diff
changeset
|
82 OopMapValue (VMReg reg, oop_types t, VMReg reg2) { set_reg_type(reg, t); set_content_reg(reg2); } |
0 | 83 OopMapValue (CompressedReadStream* stream) { read_from(stream); } |
84 | |
85 // Archiving | |
86 void write_on(CompressedWriteStream* stream) { | |
87 stream->write_int(value()); | |
88 if(is_callee_saved() || is_derived_oop()) { | |
89 stream->write_int(content_reg()->value()); | |
90 } | |
91 } | |
92 | |
93 void read_from(CompressedReadStream* stream) { | |
94 set_value(stream->read_int()); | |
23822
626f594dffa6
8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
csahu
parents:
1972
diff
changeset
|
95 if (is_callee_saved() || is_derived_oop()) { |
0 | 96 set_content_reg(VMRegImpl::as_VMReg(stream->read_int(), true)); |
97 } | |
98 } | |
99 | |
100 // Querying | |
101 bool is_oop() { return mask_bits(value(), type_mask_in_place) == oop_value; } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
102 bool is_narrowoop() { return mask_bits(value(), type_mask_in_place) == narrowoop_value; } |
0 | 103 bool is_callee_saved() { return mask_bits(value(), type_mask_in_place) == callee_saved_value; } |
104 bool is_derived_oop() { return mask_bits(value(), type_mask_in_place) == derived_oop_value; } | |
105 | |
106 void set_oop() { set_value((value() & register_mask_in_place) | oop_value); } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
107 void set_narrowoop() { set_value((value() & register_mask_in_place) | narrowoop_value); } |
0 | 108 void set_callee_saved() { set_value((value() & register_mask_in_place) | callee_saved_value); } |
109 void set_derived_oop() { set_value((value() & register_mask_in_place) | derived_oop_value); } | |
110 | |
111 VMReg reg() const { return VMRegImpl::as_VMReg(mask_bits(value(), register_mask_in_place) >> register_shift); } | |
112 oop_types type() const { return (oop_types)mask_bits(value(), type_mask_in_place); } | |
113 | |
114 static bool legal_vm_reg_name(VMReg p) { | |
115 return (p->value() == (p->value() & register_mask)); | |
116 } | |
117 | |
118 void set_reg_type(VMReg p, oop_types t) { | |
119 set_value((p->value() << register_shift) | t); | |
120 assert(reg() == p, "sanity check" ); | |
121 assert(type() == t, "sanity check" ); | |
122 } | |
123 | |
124 | |
125 VMReg content_reg() const { return VMRegImpl::as_VMReg(_content_reg, true); } | |
126 void set_content_reg(VMReg r) { _content_reg = r->value(); } | |
127 | |
128 // Physical location queries | |
129 bool is_register_loc() { return reg()->is_reg(); } | |
130 bool is_stack_loc() { return reg()->is_stack(); } | |
131 | |
132 // Returns offset from sp. | |
133 int stack_offset() { | |
134 assert(is_stack_loc(), "must be stack location"); | |
135 return reg()->reg2stack(); | |
136 } | |
137 | |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
138 void print_on(outputStream* st) const; |
25
c5cbd367e4d1
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
0
diff
changeset
|
139 void print() const { print_on(tty); } |
0 | 140 }; |
141 | |
142 | |
143 class OopMap: public ResourceObj { | |
144 friend class OopMapStream; | |
145 friend class VMStructs; | |
146 private: | |
147 int _pc_offset; | |
148 int _omv_count; | |
149 int _omv_data_size; | |
150 unsigned char* _omv_data; | |
151 CompressedWriteStream* _write_stream; | |
152 | |
153 debug_only( OopMapValue::oop_types* _locs_used; int _locs_length;) | |
154 | |
155 // Accessors | |
156 unsigned char* omv_data() const { return _omv_data; } | |
157 void set_omv_data(unsigned char* value) { _omv_data = value; } | |
158 int omv_data_size() const { return _omv_data_size; } | |
159 void set_omv_data_size(int value) { _omv_data_size = value; } | |
160 int omv_count() const { return _omv_count; } | |
161 void set_omv_count(int value) { _omv_count = value; } | |
162 void increment_count() { _omv_count++; } | |
163 CompressedWriteStream* write_stream() const { return _write_stream; } | |
164 void set_write_stream(CompressedWriteStream* value) { _write_stream = value; } | |
165 | |
166 private: | |
167 enum DeepCopyToken { _deep_copy_token }; | |
168 OopMap(DeepCopyToken, OopMap* source); // used only by deep_copy | |
169 | |
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; } | |
176 | |
177 // Check to avoid double insertion | |
178 debug_only(OopMapValue::oop_types locs_used( int indx ) { return _locs_used[indx]; }) | |
179 | |
180 // Construction | |
181 // frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd | |
182 // slots to hold 4-byte values like ints and floats in the LP64 build. | |
183 void set_oop ( VMReg local); | |
184 void set_value( VMReg local); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
185 void set_narrowoop(VMReg local); |
0 | 186 void set_dead ( VMReg local); |
187 void set_callee_saved( VMReg local, VMReg caller_machine_register ); | |
188 void set_derived_oop ( VMReg local, VMReg derived_from_local_register ); | |
189 void set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional); | |
190 | |
191 int heap_size() const; | |
192 void copy_to(address addr); | |
193 OopMap* deep_copy(); | |
194 | |
195 bool has_derived_pointer() const PRODUCT_RETURN0; | |
196 | |
197 bool legal_vm_reg_name(VMReg local) { | |
198 return OopMapValue::legal_vm_reg_name(local); | |
199 } | |
200 | |
201 // Printing | |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
202 void print_on(outputStream* st) const; |
0 | 203 void print() const { print_on(tty); } |
204 }; | |
205 | |
206 | |
207 class OopMapSet : public ResourceObj { | |
208 friend class VMStructs; | |
209 private: | |
210 int _om_count; | |
211 int _om_size; | |
212 OopMap** _om_data; | |
213 | |
214 int om_count() const { return _om_count; } | |
215 void set_om_count(int value) { _om_count = value; } | |
216 void increment_count() { _om_count++; } | |
217 int om_size() const { return _om_size; } | |
218 void set_om_size(int value) { _om_size = value; } | |
219 OopMap** om_data() const { return _om_data; } | |
220 void set_om_data(OopMap** value) { _om_data = value; } | |
221 void grow_om_data(); | |
222 void set(int index,OopMap* value) { assert((index == 0) || ((index > 0) && (index < om_size())),"bad index"); _om_data[index] = value; } | |
223 | |
224 public: | |
225 OopMapSet(); | |
226 | |
227 // returns the number of OopMaps in this OopMapSet | |
228 int size() const { return _om_count; } | |
229 // returns the OopMap at a given index | |
230 OopMap* at(int index) const { assert((index >= 0) && (index <= om_count()),"bad index"); return _om_data[index]; } | |
231 | |
232 // Collect OopMaps. | |
233 void add_gc_map(int pc, OopMap* map); | |
234 | |
235 // Returns the only oop map. Used for reconstructing | |
236 // Adapter frames during deoptimization | |
237 OopMap* singular_oop_map(); | |
238 | |
239 // returns OopMap in that is anchored to the pc | |
240 OopMap* find_map_at_offset(int pc_offset) const; | |
241 | |
242 int heap_size() const; | |
243 void copy_to(address addr); | |
244 | |
858 | 245 // Methods oops_do() and all_do() filter out NULL oops and |
246 // oop == Universe::narrow_oop_base() before passing oops | |
247 // to closures. | |
248 | |
0 | 249 // Iterates through frame for a compiled method |
250 static void oops_do (const frame* fr, | |
251 const RegisterMap* reg_map, OopClosure* f); | |
252 static void update_register_map(const frame* fr, RegisterMap *reg_map); | |
253 | |
254 // Iterates through frame for a compiled method for dead ones and values, too | |
255 static void all_do(const frame* fr, const RegisterMap* reg_map, | |
256 OopClosure* oop_fn, | |
257 void derived_oop_fn(oop* base, oop* derived), | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
258 OopClosure* value_fn); |
0 | 259 |
260 // Printing | |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
261 void print_on(outputStream* st) const; |
0 | 262 void print() const { print_on(tty); } |
263 }; | |
264 | |
265 | |
266 class OopMapStream : public StackObj { | |
267 private: | |
268 CompressedReadStream* _stream; | |
269 int _mask; | |
270 int _size; | |
271 int _position; | |
272 bool _valid_omv; | |
273 OopMapValue _omv; | |
274 void find_next(); | |
275 | |
276 public: | |
277 OopMapStream(OopMap* oop_map); | |
278 OopMapStream(OopMap* oop_map, int oop_types_mask); | |
279 bool is_done() { if(!_valid_omv) { find_next(); } return !_valid_omv; } | |
280 void next() { find_next(); } | |
281 OopMapValue current() { return _omv; } | |
282 }; | |
283 | |
284 | |
285 // Derived pointer support. This table keeps track of all derived points on a | |
286 // stack. It is cleared before each scavenge/GC. During the traversal of all | |
287 // oops, it is filled in with references to all locations that contains a | |
288 // derived oop (assumed to be very few). When the GC is complete, the derived | |
289 // pointers are updated based on their base pointers new value and an offset. | |
22298 | 290 #if defined(COMPILER2) || INCLUDE_JVMCI |
0 | 291 class DerivedPointerTable : public AllStatic { |
292 friend class VMStructs; | |
293 private: | |
294 static GrowableArray<DerivedPointerEntry*>* _list; | |
295 static bool _active; // do not record pointers for verify pass etc. | |
296 public: | |
297 static void clear(); // Called before scavenge/GC | |
298 static void add(oop *derived, oop *base); // Called during scavenge/GC | |
299 static void update_pointers(); // Called after scavenge/GC | |
300 static bool is_empty() { return _list == NULL || _list->is_empty(); } | |
301 static bool is_active() { return _active; } | |
302 static void set_active(bool value) { _active = value; } | |
303 }; | |
304 | |
305 // A utility class to temporarily "deactivate" the DerivedPointerTable. | |
306 // (Note: clients are responsible for any MT-safety issues) | |
307 class DerivedPointerTableDeactivate: public StackObj { | |
308 private: | |
309 bool _active; | |
310 public: | |
311 DerivedPointerTableDeactivate() { | |
312 _active = DerivedPointerTable::is_active(); | |
313 if (_active) { | |
314 DerivedPointerTable::set_active(false); | |
315 } | |
316 } | |
317 | |
318 ~DerivedPointerTableDeactivate() { | |
319 assert(!DerivedPointerTable::is_active(), | |
320 "Inconsistency: not MT-safe"); | |
321 if (_active) { | |
322 DerivedPointerTable::set_active(true); | |
323 } | |
324 } | |
325 }; | |
22294
d86b226e331a
Enable derived oop processing by the GC with JVMCI
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14988
diff
changeset
|
326 #endif // COMPILER2 || JVMCI |
1972 | 327 |
328 #endif // SHARE_VM_COMPILER_OOPMAP_HPP |