Mercurial > hg > graal-jvmci-8
annotate src/share/vm/compiler/oopMap.cpp @ 23408:f84a5ac3be22
make JVMCI JDK immutable and sharable among different JVMCI clients
minimize diff to jvmci-9, including adding support for EnableJVMCI (default is true in jvmci-8)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 30 May 2016 22:56:59 +0200 |
parents | 3ef45d0a6d77 |
children | 1051fbaca88b |
rev | line source |
---|---|
0 | 1 /* |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
12316
diff
changeset
|
2 * Copyright (c) 1998, 2014, 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 #include "precompiled.hpp" |
26 #include "code/codeBlob.hpp" | |
27 #include "code/codeCache.hpp" | |
28 #include "code/nmethod.hpp" | |
29 #include "code/scopeDesc.hpp" | |
30 #include "compiler/oopMap.hpp" | |
31 #include "gc_interface/collectedHeap.hpp" | |
32 #include "memory/allocation.inline.hpp" | |
33 #include "memory/resourceArea.hpp" | |
34 #include "runtime/frame.inline.hpp" | |
35 #include "runtime/signature.hpp" | |
36 #ifdef COMPILER1 | |
37 #include "c1/c1_Defs.hpp" | |
38 #endif | |
22407
708a95bb443c
All SPARC float registers can be addressed in 4 byte portions; hence don't add 4 bytes to pointer pointing to a Narrow Oop
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
22298
diff
changeset
|
39 #ifdef SPARC |
708a95bb443c
All SPARC float registers can be addressed in 4 byte portions; hence don't add 4 bytes to pointer pointing to a Narrow Oop
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
22298
diff
changeset
|
40 #include "vmreg_sparc.inline.hpp" |
708a95bb443c
All SPARC float registers can be addressed in 4 byte portions; hence don't add 4 bytes to pointer pointing to a Narrow Oop
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
22298
diff
changeset
|
41 #endif |
0 | 42 |
43 // OopMapStream | |
44 | |
45 OopMapStream::OopMapStream(OopMap* oop_map) { | |
46 if(oop_map->omv_data() == NULL) { | |
47 _stream = new CompressedReadStream(oop_map->write_stream()->buffer()); | |
48 } else { | |
49 _stream = new CompressedReadStream(oop_map->omv_data()); | |
50 } | |
51 _mask = OopMapValue::type_mask_in_place; | |
52 _size = oop_map->omv_count(); | |
53 _position = 0; | |
54 _valid_omv = false; | |
55 } | |
56 | |
57 | |
58 OopMapStream::OopMapStream(OopMap* oop_map, int oop_types_mask) { | |
59 if(oop_map->omv_data() == NULL) { | |
60 _stream = new CompressedReadStream(oop_map->write_stream()->buffer()); | |
61 } else { | |
62 _stream = new CompressedReadStream(oop_map->omv_data()); | |
63 } | |
64 _mask = oop_types_mask; | |
65 _size = oop_map->omv_count(); | |
66 _position = 0; | |
67 _valid_omv = false; | |
68 } | |
69 | |
70 | |
71 void OopMapStream::find_next() { | |
72 while(_position++ < _size) { | |
73 _omv.read_from(_stream); | |
74 if(((int)_omv.type() & _mask) > 0) { | |
75 _valid_omv = true; | |
76 return; | |
77 } | |
78 } | |
79 _valid_omv = false; | |
80 } | |
81 | |
82 | |
83 // OopMap | |
84 | |
85 // frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd | |
86 // slots to hold 4-byte values like ints and floats in the LP64 build. | |
87 OopMap::OopMap(int frame_size, int arg_count) { | |
88 // OopMaps are usually quite so small, so pick a small initial size | |
89 set_write_stream(new CompressedWriteStream(32)); | |
90 set_omv_data(NULL); | |
91 set_omv_count(0); | |
92 | |
93 #ifdef ASSERT | |
94 _locs_length = VMRegImpl::stack2reg(0)->value() + frame_size + arg_count; | |
95 _locs_used = NEW_RESOURCE_ARRAY(OopMapValue::oop_types, _locs_length); | |
96 for(int i = 0; i < _locs_length; i++) _locs_used[i] = OopMapValue::unused_value; | |
97 #endif | |
98 } | |
99 | |
100 | |
101 OopMap::OopMap(OopMap::DeepCopyToken, OopMap* source) { | |
102 // This constructor does a deep copy | |
103 // of the source OopMap. | |
104 set_write_stream(new CompressedWriteStream(source->omv_count() * 2)); | |
105 set_omv_data(NULL); | |
106 set_omv_count(0); | |
107 set_offset(source->offset()); | |
108 | |
109 #ifdef ASSERT | |
110 _locs_length = source->_locs_length; | |
111 _locs_used = NEW_RESOURCE_ARRAY(OopMapValue::oop_types, _locs_length); | |
112 for(int i = 0; i < _locs_length; i++) _locs_used[i] = OopMapValue::unused_value; | |
113 #endif | |
114 | |
115 // We need to copy the entries too. | |
116 for (OopMapStream oms(source); !oms.is_done(); oms.next()) { | |
117 OopMapValue omv = oms.current(); | |
118 omv.write_on(write_stream()); | |
119 increment_count(); | |
120 } | |
121 } | |
122 | |
123 | |
124 OopMap* OopMap::deep_copy() { | |
125 return new OopMap(_deep_copy_token, this); | |
126 } | |
127 | |
128 | |
129 void OopMap::copy_to(address addr) { | |
130 memcpy(addr,this,sizeof(OopMap)); | |
131 memcpy(addr + sizeof(OopMap),write_stream()->buffer(),write_stream()->position()); | |
132 OopMap* new_oop = (OopMap*)addr; | |
133 new_oop->set_omv_data_size(write_stream()->position()); | |
134 new_oop->set_omv_data((unsigned char *)(addr + sizeof(OopMap))); | |
135 new_oop->set_write_stream(NULL); | |
136 } | |
137 | |
138 | |
139 int OopMap::heap_size() const { | |
140 int size = sizeof(OopMap); | |
141 int align = sizeof(void *) - 1; | |
142 if(write_stream() != NULL) { | |
143 size += write_stream()->position(); | |
144 } else { | |
145 size += omv_data_size(); | |
146 } | |
147 // Align to a reasonable ending point | |
148 size = ((size+align) & ~align); | |
149 return size; | |
150 } | |
151 | |
152 // frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd | |
153 // slots to hold 4-byte values like ints and floats in the LP64 build. | |
154 void OopMap::set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional) { | |
155 | |
156 assert(reg->value() < _locs_length, "too big reg value for stack size"); | |
157 assert( _locs_used[reg->value()] == OopMapValue::unused_value, "cannot insert twice" ); | |
158 debug_only( _locs_used[reg->value()] = x; ) | |
159 | |
160 OopMapValue o(reg, x); | |
161 | |
162 if(x == OopMapValue::callee_saved_value) { | |
163 // This can never be a stack location, so we don't need to transform it. | |
164 assert(optional->is_reg(), "Trying to callee save a stack location"); | |
165 o.set_content_reg(optional); | |
166 } else if(x == OopMapValue::derived_oop_value) { | |
167 o.set_content_reg(optional); | |
168 } | |
169 | |
170 o.write_on(write_stream()); | |
171 increment_count(); | |
172 } | |
173 | |
174 | |
175 void OopMap::set_oop(VMReg reg) { | |
176 set_xxx(reg, OopMapValue::oop_value, VMRegImpl::Bad()); | |
177 } | |
178 | |
179 | |
180 void OopMap::set_value(VMReg reg) { | |
181 // At this time, we only need value entries in our OopMap when ZapDeadCompiledLocals is active. | |
182 } | |
183 | |
184 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
185 void OopMap::set_narrowoop(VMReg reg) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
186 set_xxx(reg, OopMapValue::narrowoop_value, VMRegImpl::Bad()); |
0 | 187 } |
188 | |
189 | |
190 void OopMap::set_callee_saved(VMReg reg, VMReg caller_machine_register ) { | |
191 set_xxx(reg, OopMapValue::callee_saved_value, caller_machine_register); | |
192 } | |
193 | |
194 | |
195 void OopMap::set_derived_oop(VMReg reg, VMReg derived_from_local_register ) { | |
196 if( reg == derived_from_local_register ) { | |
197 // Actually an oop, derived shares storage with base, | |
198 set_oop(reg); | |
199 } else { | |
200 set_xxx(reg, OopMapValue::derived_oop_value, derived_from_local_register); | |
201 } | |
202 } | |
203 | |
204 // OopMapSet | |
205 | |
206 OopMapSet::OopMapSet() { | |
207 set_om_size(MinOopMapAllocation); | |
208 set_om_count(0); | |
209 OopMap** temp = NEW_RESOURCE_ARRAY(OopMap*, om_size()); | |
210 set_om_data(temp); | |
211 } | |
212 | |
213 | |
214 void OopMapSet::grow_om_data() { | |
215 int new_size = om_size() * 2; | |
216 OopMap** new_data = NEW_RESOURCE_ARRAY(OopMap*, new_size); | |
217 memcpy(new_data,om_data(),om_size() * sizeof(OopMap*)); | |
218 set_om_size(new_size); | |
219 set_om_data(new_data); | |
220 } | |
221 | |
222 | |
223 void OopMapSet::copy_to(address addr) { | |
224 address temp = addr; | |
225 int align = sizeof(void *) - 1; | |
226 // Copy this | |
227 memcpy(addr,this,sizeof(OopMapSet)); | |
228 temp += sizeof(OopMapSet); | |
229 temp = (address)((intptr_t)(temp + align) & ~align); | |
230 // Do the needed fixups to the new OopMapSet | |
231 OopMapSet* new_set = (OopMapSet*)addr; | |
232 new_set->set_om_data((OopMap**)temp); | |
233 // Allow enough space for the OopMap pointers | |
234 temp += (om_count() * sizeof(OopMap*)); | |
235 | |
236 for(int i=0; i < om_count(); i++) { | |
237 OopMap* map = at(i); | |
238 map->copy_to((address)temp); | |
239 new_set->set(i,(OopMap*)temp); | |
240 temp += map->heap_size(); | |
241 } | |
242 // This "locks" the OopMapSet | |
243 new_set->set_om_size(-1); | |
244 } | |
245 | |
246 | |
247 void OopMapSet::add_gc_map(int pc_offset, OopMap *map ) { | |
248 assert(om_size() != -1,"Cannot grow a fixed OopMapSet"); | |
249 | |
250 if(om_count() >= om_size()) { | |
251 grow_om_data(); | |
252 } | |
253 map->set_offset(pc_offset); | |
254 | |
255 #ifdef ASSERT | |
256 if(om_count() > 0) { | |
257 OopMap* last = at(om_count()-1); | |
258 if (last->offset() == map->offset() ) { | |
259 fatal("OopMap inserted twice"); | |
260 } | |
261 if(last->offset() > map->offset()) { | |
262 tty->print_cr( "WARNING, maps not sorted: pc[%d]=%d, pc[%d]=%d", | |
263 om_count(),last->offset(),om_count()+1,map->offset()); | |
264 } | |
265 } | |
266 #endif // ASSERT | |
267 | |
268 set(om_count(),map); | |
269 increment_count(); | |
270 } | |
271 | |
272 | |
273 int OopMapSet::heap_size() const { | |
274 // The space we use | |
275 int size = sizeof(OopMap); | |
276 int align = sizeof(void *) - 1; | |
277 size = ((size+align) & ~align); | |
278 size += om_count() * sizeof(OopMap*); | |
279 | |
280 // Now add in the space needed for the indivdiual OopMaps | |
281 for(int i=0; i < om_count(); i++) { | |
282 size += at(i)->heap_size(); | |
283 } | |
284 // We don't need to align this, it will be naturally pointer aligned | |
285 return size; | |
286 } | |
287 | |
288 | |
289 OopMap* OopMapSet::singular_oop_map() { | |
290 guarantee(om_count() == 1, "Make sure we only have a single gc point"); | |
291 return at(0); | |
292 } | |
293 | |
294 | |
295 OopMap* OopMapSet::find_map_at_offset(int pc_offset) const { | |
296 int i, len = om_count(); | |
297 assert( len > 0, "must have pointer maps" ); | |
298 | |
299 // Scan through oopmaps. Stop when current offset is either equal or greater | |
300 // than the one we are looking for. | |
301 for( i = 0; i < len; i++) { | |
302 if( at(i)->offset() >= pc_offset ) | |
303 break; | |
304 } | |
305 | |
306 assert( i < len, "oopmap not found" ); | |
307 | |
308 OopMap* m = at(i); | |
309 assert( m->offset() == pc_offset, "oopmap not found" ); | |
310 return m; | |
311 } | |
312 | |
313 class DoNothingClosure: public OopClosure { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
314 public: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
315 void do_oop(oop* p) {} |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
316 void do_oop(narrowOop* p) {} |
0 | 317 }; |
318 static DoNothingClosure do_nothing; | |
319 | |
320 static void add_derived_oop(oop* base, oop* derived) { | |
321 #ifndef TIERED | |
322 COMPILER1_PRESENT(ShouldNotReachHere();) | |
323 #endif // TIERED | |
22298 | 324 #if defined(COMPILER2) || INCLUDE_JVMCI |
0 | 325 DerivedPointerTable::add(derived, base); |
22294
d86b226e331a
Enable derived oop processing by the GC with JVMCI
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21559
diff
changeset
|
326 #endif // COMPILER2 || JVMCI |
0 | 327 } |
328 | |
329 | |
330 #ifndef PRODUCT | |
331 static void trace_codeblob_maps(const frame *fr, const RegisterMap *reg_map) { | |
332 // Print oopmap and regmap | |
333 tty->print_cr("------ "); | |
334 CodeBlob* cb = fr->cb(); | |
335 OopMapSet* maps = cb->oop_maps(); | |
336 OopMap* map = cb->oop_map_for_return_address(fr->pc()); | |
337 map->print(); | |
338 if( cb->is_nmethod() ) { | |
339 nmethod* nm = (nmethod*)cb; | |
340 // native wrappers have no scope data, it is implied | |
341 if (nm->is_native_method()) { | |
342 tty->print("bci: 0 (native)"); | |
343 } else { | |
344 ScopeDesc* scope = nm->scope_desc_at(fr->pc()); | |
345 tty->print("bci: %d ",scope->bci()); | |
346 } | |
347 } | |
348 tty->cr(); | |
349 fr->print_on(tty); | |
350 tty->print(" "); | |
351 cb->print_value_on(tty); tty->cr(); | |
352 reg_map->print(); | |
353 tty->print_cr("------ "); | |
354 | |
355 } | |
356 #endif // PRODUCT | |
357 | |
358 void OopMapSet::oops_do(const frame *fr, const RegisterMap* reg_map, OopClosure* f) { | |
359 // add derived oops to a table | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
360 all_do(fr, reg_map, f, add_derived_oop, &do_nothing); |
0 | 361 } |
362 | |
363 | |
364 void OopMapSet::all_do(const frame *fr, const RegisterMap *reg_map, | |
365 OopClosure* oop_fn, void derived_oop_fn(oop*, oop*), | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
366 OopClosure* value_fn) { |
0 | 367 CodeBlob* cb = fr->cb(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
368 assert(cb != NULL, "no codeblob"); |
0 | 369 |
370 NOT_PRODUCT(if (TraceCodeBlobStacks) trace_codeblob_maps(fr, reg_map);) | |
371 | |
372 OopMapSet* maps = cb->oop_maps(); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
373 OopMap* map = cb->oop_map_for_return_address(fr->pc()); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
374 assert(map != NULL, "no ptr map found"); |
0 | 375 |
376 // handle derived pointers first (otherwise base pointer may be | |
377 // changed before derived pointer offset has been collected) | |
378 OopMapValue omv; | |
379 { | |
380 OopMapStream oms(map,OopMapValue::derived_oop_value); | |
381 if (!oms.is_done()) { | |
382 #ifndef TIERED | |
383 COMPILER1_PRESENT(ShouldNotReachHere();) | |
384 #endif // !TIERED | |
385 // Protect the operation on the derived pointers. This | |
386 // protects the addition of derived pointers to the shared | |
387 // derived pointer table in DerivedPointerTable::add(). | |
388 MutexLockerEx x(DerivedPointerTableGC_lock, Mutex::_no_safepoint_check_flag); | |
389 do { | |
390 omv = oms.current(); | |
391 oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map); | |
20969
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
392 guarantee(loc != NULL, "missing saved register"); |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
393 oop *base_loc = fr->oopmapreg_to_location(omv.content_reg(), reg_map); |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
394 oop *derived_loc = loc; |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
395 oop val = *base_loc; |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
396 if (val == (oop)NULL || Universe::is_narrow_oop_base(val)) { |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
397 // Ignore NULL oops and decoded NULL narrow oops which |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
398 // equal to Universe::narrow_oop_base when a narrow oop |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
399 // implicit null check is used in compiled code. |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
400 // The narrow_oop_base could be NULL or be the address |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
401 // of the page below heap depending on compressed oops mode. |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
402 } else { |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
403 derived_oop_fn(base_loc, derived_loc); |
0 | 404 } |
405 oms.next(); | |
406 } while (!oms.is_done()); | |
407 } | |
408 } | |
409 | |
20969
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
410 // We want narrowoop and oop oop_types |
14988
82ff6c8c8f6e
Increase maximum allocatable spill area by factor of 2.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14124
diff
changeset
|
411 int mask = OopMapValue::oop_value | OopMapValue::narrowoop_value; |
0 | 412 { |
413 for (OopMapStream oms(map,mask); !oms.is_done(); oms.next()) { | |
414 omv = oms.current(); | |
415 oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map); | |
20969
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
416 // It should be an error if no location can be found for a |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
417 // register mentioned as contained an oop of some kind. Maybe |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
418 // this was allowed previously because value_value items might |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
419 // be missing? |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
420 guarantee(loc != NULL, "missing saved register"); |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
421 if ( omv.type() == OopMapValue::oop_value ) { |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
422 oop val = *loc; |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
423 if (val == (oop)NULL || Universe::is_narrow_oop_base(val)) { |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
424 // Ignore NULL oops and decoded NULL narrow oops which |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
425 // equal to Universe::narrow_oop_base when a narrow oop |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
426 // implicit null check is used in compiled code. |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
427 // The narrow_oop_base could be NULL or be the address |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
428 // of the page below heap depending on compressed oops mode. |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
429 continue; |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
430 } |
0 | 431 #ifdef ASSERT |
20969
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
432 if ((((uintptr_t)loc & (sizeof(*loc)-1)) != 0) || |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
433 !Universe::heap()->is_in_or_null(*loc)) { |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
434 tty->print_cr("# Found non oop pointer. Dumping state at failure"); |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
435 // try to dump out some helpful debugging information |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
436 trace_codeblob_maps(fr, reg_map); |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
437 omv.print(); |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
438 tty->print_cr("register r"); |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
439 omv.reg()->print(); |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
440 tty->print_cr("loc = %p *loc = %p\n", loc, (address)*loc); |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
441 // do the real assert. |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
442 assert(Universe::heap()->is_in_or_null(*loc), "found non oop pointer"); |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
443 } |
0 | 444 #endif // ASSERT |
20969
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
445 oop_fn->do_oop(loc); |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
446 } else if ( omv.type() == OopMapValue::narrowoop_value ) { |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
447 narrowOop *nl = (narrowOop*)loc; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
448 #ifndef VM_LITTLE_ENDIAN |
22407
708a95bb443c
All SPARC float registers can be addressed in 4 byte portions; hence don't add 4 bytes to pointer pointing to a Narrow Oop
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
22298
diff
changeset
|
449 VMReg vmReg = omv.reg(); |
708a95bb443c
All SPARC float registers can be addressed in 4 byte portions; hence don't add 4 bytes to pointer pointing to a Narrow Oop
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
22298
diff
changeset
|
450 // Don't do this on SPARC float registers as they can be individually addressed |
708a95bb443c
All SPARC float registers can be addressed in 4 byte portions; hence don't add 4 bytes to pointer pointing to a Narrow Oop
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
22298
diff
changeset
|
451 if (!vmReg->is_stack() SPARC_ONLY(&& !vmReg->is_FloatRegister())) { |
20969
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
452 // compressed oops in registers only take up 4 bytes of an |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
453 // 8 byte register but they are in the wrong part of the |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
454 // word so adjust loc to point at the right place. |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
455 nl = (narrowOop*)((address)nl + 4); |
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
456 } |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
457 #endif |
20969
534f0dde2810
It should be an error for an OopMap to mention a register that can't be found
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20804
diff
changeset
|
458 oop_fn->do_oop(nl); |
0 | 459 } |
460 } | |
461 } | |
462 } | |
463 | |
464 | |
465 // Update callee-saved register info for the following frame | |
466 void OopMapSet::update_register_map(const frame *fr, RegisterMap *reg_map) { | |
467 ResourceMark rm; | |
468 CodeBlob* cb = fr->cb(); | |
469 assert(cb != NULL, "no codeblob"); | |
470 | |
471 // Any reg might be saved by a safepoint handler (see generate_handler_blob). | |
472 assert( reg_map->_update_for_id == NULL || fr->is_older(reg_map->_update_for_id), | |
473 "already updated this map; do not 'update' it twice!" ); | |
474 debug_only(reg_map->_update_for_id = fr->id()); | |
475 | |
476 // Check if caller must update oop argument | |
477 assert((reg_map->include_argument_oops() || | |
478 !cb->caller_must_gc_arguments(reg_map->thread())), | |
479 "include_argument_oops should already be set"); | |
480 | |
481 // Scan through oopmap and find location of all callee-saved registers | |
482 // (we do not do update in place, since info could be overwritten) | |
483 | |
484 address pc = fr->pc(); | |
485 OopMap* map = cb->oop_map_for_return_address(pc); | |
20226
6ad19ab94176
8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
17937
diff
changeset
|
486 assert(map != NULL, "no ptr map found"); |
6ad19ab94176
8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
17937
diff
changeset
|
487 DEBUG_ONLY(int nof_callee = 0;) |
0 | 488 |
20226
6ad19ab94176
8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
17937
diff
changeset
|
489 for (OopMapStream oms(map, OopMapValue::callee_saved_value); !oms.is_done(); oms.next()) { |
6ad19ab94176
8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
17937
diff
changeset
|
490 OopMapValue omv = oms.current(); |
6ad19ab94176
8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
17937
diff
changeset
|
491 VMReg reg = omv.content_reg(); |
6ad19ab94176
8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
17937
diff
changeset
|
492 oop* loc = fr->oopmapreg_to_location(omv.reg(), reg_map); |
6ad19ab94176
8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
17937
diff
changeset
|
493 reg_map->set_location(reg, (address) loc); |
6ad19ab94176
8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
17937
diff
changeset
|
494 DEBUG_ONLY(nof_callee++;) |
0 | 495 } |
496 | |
497 // Check that runtime stubs save all callee-saved registers | |
498 #ifdef COMPILER2 | |
21559
be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20969
diff
changeset
|
499 assert(cb->is_compiled_by_c1() || cb->is_compiled_by_jvmci() || !cb->is_runtime_stub() || |
0 | 500 (nof_callee >= SAVED_ON_ENTRY_REG_COUNT || nof_callee >= C_SAVED_ON_ENTRY_REG_COUNT), |
501 "must save all"); | |
502 #endif // COMPILER2 | |
503 } | |
504 | |
505 //============================================================================= | |
506 // Non-Product code | |
507 | |
508 #ifndef PRODUCT | |
509 | |
510 bool OopMap::has_derived_pointer() const { | |
511 #ifndef TIERED | |
512 COMPILER1_PRESENT(return false); | |
513 #endif // !TIERED | |
22298 | 514 #if defined(COMPILER2) || INCLUDE_JVMCI |
0 | 515 OopMapStream oms((OopMap*)this,OopMapValue::derived_oop_value); |
516 return oms.is_done(); | |
517 #else | |
518 return false; | |
22294
d86b226e331a
Enable derived oop processing by the GC with JVMCI
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21559
diff
changeset
|
519 #endif // COMPILER2 || JVMCI |
0 | 520 } |
521 | |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
522 #endif //PRODUCT |
0 | 523 |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
524 // Printing code is present in product build for -XX:+PrintAssembly. |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
525 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
526 static |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
527 void print_register_type(OopMapValue::oop_types x, VMReg optional, |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
528 outputStream* st) { |
0 | 529 switch( x ) { |
530 case OopMapValue::oop_value: | |
25
c5cbd367e4d1
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
0
diff
changeset
|
531 st->print("Oop"); |
0 | 532 break; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
533 case OopMapValue::narrowoop_value: |
7636
a7114d3d712e
8005055: pass outputStream to more opto debug routines
kvn
parents:
6842
diff
changeset
|
534 st->print("NarrowOop"); |
0 | 535 break; |
536 case OopMapValue::callee_saved_value: | |
7636
a7114d3d712e
8005055: pass outputStream to more opto debug routines
kvn
parents:
6842
diff
changeset
|
537 st->print("Callers_"); |
25
c5cbd367e4d1
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
0
diff
changeset
|
538 optional->print_on(st); |
0 | 539 break; |
540 case OopMapValue::derived_oop_value: | |
7636
a7114d3d712e
8005055: pass outputStream to more opto debug routines
kvn
parents:
6842
diff
changeset
|
541 st->print("Derived_oop_"); |
25
c5cbd367e4d1
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
0
diff
changeset
|
542 optional->print_on(st); |
0 | 543 break; |
544 default: | |
545 ShouldNotReachHere(); | |
546 } | |
547 } | |
548 | |
549 | |
25
c5cbd367e4d1
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
0
diff
changeset
|
550 void OopMapValue::print_on(outputStream* st) const { |
c5cbd367e4d1
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
0
diff
changeset
|
551 reg()->print_on(st); |
c5cbd367e4d1
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
0
diff
changeset
|
552 st->print("="); |
c5cbd367e4d1
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
0
diff
changeset
|
553 print_register_type(type(),content_reg(),st); |
c5cbd367e4d1
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
0
diff
changeset
|
554 st->print(" "); |
0 | 555 } |
556 | |
557 | |
558 void OopMap::print_on(outputStream* st) const { | |
559 OopMapValue omv; | |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
560 st->print("OopMap{"); |
0 | 561 for(OopMapStream oms((OopMap*)this); !oms.is_done(); oms.next()) { |
562 omv = oms.current(); | |
563 omv.print_on(st); | |
564 } | |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
565 st->print("off=%d}", (int) offset()); |
0 | 566 } |
567 | |
568 | |
569 void OopMapSet::print_on(outputStream* st) const { | |
570 int i, len = om_count(); | |
571 | |
572 st->print_cr("OopMapSet contains %d OopMaps\n",len); | |
573 | |
574 for( i = 0; i < len; i++) { | |
575 OopMap* m = at(i); | |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
576 st->print_cr("#%d ",i); |
0 | 577 m->print_on(st); |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
578 st->cr(); |
0 | 579 } |
580 } | |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
581 |
0 | 582 |
583 | |
584 //------------------------------DerivedPointerTable--------------------------- | |
585 | |
22298 | 586 #if defined(COMPILER2) || INCLUDE_JVMCI |
0 | 587 |
6197 | 588 class DerivedPointerEntry : public CHeapObj<mtCompiler> { |
0 | 589 private: |
590 oop* _location; // Location of derived pointer (also pointing to the base) | |
591 intptr_t _offset; // Offset from base pointer | |
592 public: | |
593 DerivedPointerEntry(oop* location, intptr_t offset) { _location = location; _offset = offset; } | |
594 oop* location() { return _location; } | |
595 intptr_t offset() { return _offset; } | |
596 }; | |
597 | |
598 | |
599 GrowableArray<DerivedPointerEntry*>* DerivedPointerTable::_list = NULL; | |
600 bool DerivedPointerTable::_active = false; | |
601 | |
602 | |
603 void DerivedPointerTable::clear() { | |
604 // The first time, we create the list. Otherwise it should be | |
605 // empty. If not, then we have probably forgotton to call | |
606 // update_pointers after last GC/Scavenge. | |
607 assert (!_active, "should not be active"); | |
608 assert(_list == NULL || _list->length() == 0, "table not empty"); | |
609 if (_list == NULL) { | |
6197 | 610 _list = new (ResourceObj::C_HEAP, mtCompiler) GrowableArray<DerivedPointerEntry*>(10, true); // Allocated on C heap |
0 | 611 } |
612 _active = true; | |
613 } | |
614 | |
615 | |
616 // Returns value of location as an int | |
12316
190899198332
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
7636
diff
changeset
|
617 intptr_t value_of_loc(oop *pointer) { return cast_from_oop<intptr_t>((*pointer)); } |
0 | 618 |
619 | |
620 void DerivedPointerTable::add(oop *derived_loc, oop *base_loc) { | |
621 assert(Universe::heap()->is_in_or_null(*base_loc), "not an oop"); | |
622 assert(derived_loc != base_loc, "Base and derived in same location"); | |
623 if (_active) { | |
624 assert(*derived_loc != (oop)base_loc, "location already added"); | |
625 assert(_list != NULL, "list must exist"); | |
626 intptr_t offset = value_of_loc(derived_loc) - value_of_loc(base_loc); | |
3442
f7d55ea6ee56
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
1972
diff
changeset
|
627 // This assert is invalid because derived pointers can be |
f7d55ea6ee56
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
1972
diff
changeset
|
628 // arbitrarily far away from their base. |
f7d55ea6ee56
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
1972
diff
changeset
|
629 // assert(offset >= -1000000, "wrong derived pointer info"); |
0 | 630 |
631 if (TraceDerivedPointers) { | |
632 tty->print_cr( | |
633 "Add derived pointer@" INTPTR_FORMAT | |
634 " - Derived: " INTPTR_FORMAT | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
12316
diff
changeset
|
635 " Base: " INTPTR_FORMAT " (@" INTPTR_FORMAT ") (Offset: " INTX_FORMAT ")", |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
12316
diff
changeset
|
636 p2i(derived_loc), p2i((address)*derived_loc), p2i((address)*base_loc), p2i(base_loc), offset |
0 | 637 ); |
638 } | |
639 // Set derived oop location to point to base. | |
640 *derived_loc = (oop)base_loc; | |
641 assert_lock_strong(DerivedPointerTableGC_lock); | |
642 DerivedPointerEntry *entry = new DerivedPointerEntry(derived_loc, offset); | |
643 _list->append(entry); | |
644 } | |
645 } | |
646 | |
647 | |
648 void DerivedPointerTable::update_pointers() { | |
649 assert(_list != NULL, "list must exist"); | |
650 for(int i = 0; i < _list->length(); i++) { | |
651 DerivedPointerEntry* entry = _list->at(i); | |
652 oop* derived_loc = entry->location(); | |
653 intptr_t offset = entry->offset(); | |
654 // The derived oop was setup to point to location of base | |
655 oop base = **(oop**)derived_loc; | |
656 assert(Universe::heap()->is_in_or_null(base), "must be an oop"); | |
657 | |
658 *derived_loc = (oop)(((address)base) + offset); | |
659 assert(value_of_loc(derived_loc) - value_of_loc(&base) == offset, "sanity check"); | |
660 | |
661 if (TraceDerivedPointers) { | |
662 tty->print_cr("Updating derived pointer@" INTPTR_FORMAT | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
12316
diff
changeset
|
663 " - Derived: " INTPTR_FORMAT " Base: " INTPTR_FORMAT " (Offset: " INTX_FORMAT ")", |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
12316
diff
changeset
|
664 p2i(derived_loc), p2i((address)*derived_loc), p2i((address)base), offset); |
0 | 665 } |
666 | |
667 // Delete entry | |
668 delete entry; | |
669 _list->at_put(i, NULL); | |
670 } | |
671 // Clear list, so it is ready for next traversal (this is an invariant) | |
672 if (TraceDerivedPointers && !_list->is_empty()) { | |
673 tty->print_cr("--------------------------"); | |
674 } | |
675 _list->clear(); | |
676 _active = false; | |
677 } | |
678 | |
22294
d86b226e331a
Enable derived oop processing by the GC with JVMCI
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21559
diff
changeset
|
679 #endif // COMPILER2 || JVMCI |