Mercurial > hg > graal-jvmci-8
annotate src/share/vm/compiler/oopMap.cpp @ 23295:c3ebefa1c743
Backed out changeset 5d04cfbd1945
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 29 Jan 2016 22:55:42 +0100 |
parents | 708a95bb443c |
children | 3ef45d0a6d77 |
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();) | |
21559
be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20969
diff
changeset
|
323 COMPILERJVMCI_PRESENT(ShouldNotReachHere();) |
0 | 324 #endif // TIERED |
22298 | 325 #if defined(COMPILER2) || INCLUDE_JVMCI |
0 | 326 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
|
327 #endif // COMPILER2 || JVMCI |
0 | 328 } |
329 | |
330 | |
331 #ifndef PRODUCT | |
332 static void trace_codeblob_maps(const frame *fr, const RegisterMap *reg_map) { | |
333 // Print oopmap and regmap | |
334 tty->print_cr("------ "); | |
335 CodeBlob* cb = fr->cb(); | |
336 OopMapSet* maps = cb->oop_maps(); | |
337 OopMap* map = cb->oop_map_for_return_address(fr->pc()); | |
338 map->print(); | |
339 if( cb->is_nmethod() ) { | |
340 nmethod* nm = (nmethod*)cb; | |
341 // native wrappers have no scope data, it is implied | |
342 if (nm->is_native_method()) { | |
343 tty->print("bci: 0 (native)"); | |
344 } else { | |
345 ScopeDesc* scope = nm->scope_desc_at(fr->pc()); | |
346 tty->print("bci: %d ",scope->bci()); | |
347 } | |
348 } | |
349 tty->cr(); | |
350 fr->print_on(tty); | |
351 tty->print(" "); | |
352 cb->print_value_on(tty); tty->cr(); | |
353 reg_map->print(); | |
354 tty->print_cr("------ "); | |
355 | |
356 } | |
357 #endif // PRODUCT | |
358 | |
359 void OopMapSet::oops_do(const frame *fr, const RegisterMap* reg_map, OopClosure* f) { | |
360 // 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
|
361 all_do(fr, reg_map, f, add_derived_oop, &do_nothing); |
0 | 362 } |
363 | |
364 | |
365 void OopMapSet::all_do(const frame *fr, const RegisterMap *reg_map, | |
366 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
|
367 OopClosure* value_fn) { |
0 | 368 CodeBlob* cb = fr->cb(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
369 assert(cb != NULL, "no codeblob"); |
0 | 370 |
371 NOT_PRODUCT(if (TraceCodeBlobStacks) trace_codeblob_maps(fr, reg_map);) | |
372 | |
373 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
|
374 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
|
375 assert(map != NULL, "no ptr map found"); |
0 | 376 |
377 // handle derived pointers first (otherwise base pointer may be | |
378 // changed before derived pointer offset has been collected) | |
379 OopMapValue omv; | |
380 { | |
381 OopMapStream oms(map,OopMapValue::derived_oop_value); | |
382 if (!oms.is_done()) { | |
383 #ifndef TIERED | |
384 COMPILER1_PRESENT(ShouldNotReachHere();) | |
21559
be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20969
diff
changeset
|
385 COMPILERJVMCI_PRESENT(ShouldNotReachHere();) |
0 | 386 #endif // !TIERED |
387 // Protect the operation on the derived pointers. This | |
388 // protects the addition of derived pointers to the shared | |
389 // derived pointer table in DerivedPointerTable::add(). | |
390 MutexLockerEx x(DerivedPointerTableGC_lock, Mutex::_no_safepoint_check_flag); | |
391 do { | |
392 omv = oms.current(); | |
393 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
|
394 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
|
395 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
|
396 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
|
397 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
|
398 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
|
399 // 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
|
400 // 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
|
401 // 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
|
402 // 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
|
403 // 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
|
404 } 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
|
405 derived_oop_fn(base_loc, derived_loc); |
0 | 406 } |
407 oms.next(); | |
408 } while (!oms.is_done()); | |
409 } | |
410 } | |
411 | |
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
|
412 // 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
|
413 int mask = OopMapValue::oop_value | OopMapValue::narrowoop_value; |
0 | 414 { |
415 for (OopMapStream oms(map,mask); !oms.is_done(); oms.next()) { | |
416 omv = oms.current(); | |
417 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
|
418 // 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
|
419 // 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
|
420 // 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
|
421 // 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
|
422 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
|
423 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
|
424 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
|
425 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
|
426 // 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
|
427 // 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
|
428 // 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
|
429 // 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
|
430 // 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
|
431 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
|
432 } |
0 | 433 #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
|
434 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
|
435 !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
|
436 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
|
437 // 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
|
438 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
|
439 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
|
440 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
|
441 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
|
442 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
|
443 // 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
|
444 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
|
445 } |
0 | 446 #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
|
447 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
|
448 } 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
|
449 narrowOop *nl = (narrowOop*)loc; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
450 #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
|
451 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
|
452 // 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
|
453 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
|
454 // 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
|
455 // 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
|
456 // 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
|
457 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
|
458 } |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
459 #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
|
460 oop_fn->do_oop(nl); |
0 | 461 } |
462 } | |
463 } | |
464 } | |
465 | |
466 | |
467 // Update callee-saved register info for the following frame | |
468 void OopMapSet::update_register_map(const frame *fr, RegisterMap *reg_map) { | |
469 ResourceMark rm; | |
470 CodeBlob* cb = fr->cb(); | |
471 assert(cb != NULL, "no codeblob"); | |
472 | |
473 // Any reg might be saved by a safepoint handler (see generate_handler_blob). | |
474 assert( reg_map->_update_for_id == NULL || fr->is_older(reg_map->_update_for_id), | |
475 "already updated this map; do not 'update' it twice!" ); | |
476 debug_only(reg_map->_update_for_id = fr->id()); | |
477 | |
478 // Check if caller must update oop argument | |
479 assert((reg_map->include_argument_oops() || | |
480 !cb->caller_must_gc_arguments(reg_map->thread())), | |
481 "include_argument_oops should already be set"); | |
482 | |
483 // Scan through oopmap and find location of all callee-saved registers | |
484 // (we do not do update in place, since info could be overwritten) | |
485 | |
486 address pc = fr->pc(); | |
487 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
|
488 assert(map != NULL, "no ptr map found"); |
6ad19ab94176
8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
17937
diff
changeset
|
489 DEBUG_ONLY(int nof_callee = 0;) |
0 | 490 |
20226
6ad19ab94176
8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
17937
diff
changeset
|
491 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
|
492 OopMapValue omv = oms.current(); |
6ad19ab94176
8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
17937
diff
changeset
|
493 VMReg reg = omv.content_reg(); |
6ad19ab94176
8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
17937
diff
changeset
|
494 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
|
495 reg_map->set_location(reg, (address) loc); |
6ad19ab94176
8050229: Uninitialised memory in hotspot/src/share/vm/compiler/oopMap.cpp
morris
parents:
17937
diff
changeset
|
496 DEBUG_ONLY(nof_callee++;) |
0 | 497 } |
498 | |
499 // Check that runtime stubs save all callee-saved registers | |
500 #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
|
501 assert(cb->is_compiled_by_c1() || cb->is_compiled_by_jvmci() || !cb->is_runtime_stub() || |
0 | 502 (nof_callee >= SAVED_ON_ENTRY_REG_COUNT || nof_callee >= C_SAVED_ON_ENTRY_REG_COUNT), |
503 "must save all"); | |
504 #endif // COMPILER2 | |
505 } | |
506 | |
507 //============================================================================= | |
508 // Non-Product code | |
509 | |
510 #ifndef PRODUCT | |
511 | |
512 bool OopMap::has_derived_pointer() const { | |
513 #ifndef TIERED | |
514 COMPILER1_PRESENT(return false); | |
21559
be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20969
diff
changeset
|
515 COMPILERJVMCI_PRESENT(return false); |
0 | 516 #endif // !TIERED |
22298 | 517 #if defined(COMPILER2) || INCLUDE_JVMCI |
0 | 518 OopMapStream oms((OopMap*)this,OopMapValue::derived_oop_value); |
519 return oms.is_done(); | |
520 #else | |
521 return false; | |
22294
d86b226e331a
Enable derived oop processing by the GC with JVMCI
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21559
diff
changeset
|
522 #endif // COMPILER2 || JVMCI |
0 | 523 } |
524 | |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
525 #endif //PRODUCT |
0 | 526 |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
527 // 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
|
528 |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
529 static |
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
530 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
|
531 outputStream* st) { |
0 | 532 switch( x ) { |
533 case OopMapValue::oop_value: | |
25
c5cbd367e4d1
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
0
diff
changeset
|
534 st->print("Oop"); |
0 | 535 break; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
100
diff
changeset
|
536 case OopMapValue::narrowoop_value: |
7636
a7114d3d712e
8005055: pass outputStream to more opto debug routines
kvn
parents:
6842
diff
changeset
|
537 st->print("NarrowOop"); |
0 | 538 break; |
539 case OopMapValue::callee_saved_value: | |
7636
a7114d3d712e
8005055: pass outputStream to more opto debug routines
kvn
parents:
6842
diff
changeset
|
540 st->print("Callers_"); |
25
c5cbd367e4d1
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
0
diff
changeset
|
541 optional->print_on(st); |
0 | 542 break; |
543 case OopMapValue::derived_oop_value: | |
7636
a7114d3d712e
8005055: pass outputStream to more opto debug routines
kvn
parents:
6842
diff
changeset
|
544 st->print("Derived_oop_"); |
25
c5cbd367e4d1
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
0
diff
changeset
|
545 optional->print_on(st); |
0 | 546 break; |
547 default: | |
548 ShouldNotReachHere(); | |
549 } | |
550 } | |
551 | |
552 | |
25
c5cbd367e4d1
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
0
diff
changeset
|
553 void OopMapValue::print_on(outputStream* st) const { |
c5cbd367e4d1
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
0
diff
changeset
|
554 reg()->print_on(st); |
c5cbd367e4d1
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
0
diff
changeset
|
555 st->print("="); |
c5cbd367e4d1
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
0
diff
changeset
|
556 print_register_type(type(),content_reg(),st); |
c5cbd367e4d1
6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents:
0
diff
changeset
|
557 st->print(" "); |
0 | 558 } |
559 | |
560 | |
561 void OopMap::print_on(outputStream* st) const { | |
562 OopMapValue omv; | |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
563 st->print("OopMap{"); |
0 | 564 for(OopMapStream oms((OopMap*)this); !oms.is_done(); oms.next()) { |
565 omv = oms.current(); | |
566 omv.print_on(st); | |
567 } | |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
568 st->print("off=%d}", (int) offset()); |
0 | 569 } |
570 | |
571 | |
572 void OopMapSet::print_on(outputStream* st) const { | |
573 int i, len = om_count(); | |
574 | |
575 st->print_cr("OopMapSet contains %d OopMaps\n",len); | |
576 | |
577 for( i = 0; i < len; i++) { | |
578 OopMap* m = at(i); | |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
579 st->print_cr("#%d ",i); |
0 | 580 m->print_on(st); |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
581 st->cr(); |
0 | 582 } |
583 } | |
100
c7c777385a15
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
25
diff
changeset
|
584 |
0 | 585 |
586 | |
587 //------------------------------DerivedPointerTable--------------------------- | |
588 | |
22298 | 589 #if defined(COMPILER2) || INCLUDE_JVMCI |
0 | 590 |
6197 | 591 class DerivedPointerEntry : public CHeapObj<mtCompiler> { |
0 | 592 private: |
593 oop* _location; // Location of derived pointer (also pointing to the base) | |
594 intptr_t _offset; // Offset from base pointer | |
595 public: | |
596 DerivedPointerEntry(oop* location, intptr_t offset) { _location = location; _offset = offset; } | |
597 oop* location() { return _location; } | |
598 intptr_t offset() { return _offset; } | |
599 }; | |
600 | |
601 | |
602 GrowableArray<DerivedPointerEntry*>* DerivedPointerTable::_list = NULL; | |
603 bool DerivedPointerTable::_active = false; | |
604 | |
605 | |
606 void DerivedPointerTable::clear() { | |
607 // The first time, we create the list. Otherwise it should be | |
608 // empty. If not, then we have probably forgotton to call | |
609 // update_pointers after last GC/Scavenge. | |
610 assert (!_active, "should not be active"); | |
611 assert(_list == NULL || _list->length() == 0, "table not empty"); | |
612 if (_list == NULL) { | |
6197 | 613 _list = new (ResourceObj::C_HEAP, mtCompiler) GrowableArray<DerivedPointerEntry*>(10, true); // Allocated on C heap |
0 | 614 } |
615 _active = true; | |
616 } | |
617 | |
618 | |
619 // Returns value of location as an int | |
12316
190899198332
7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents:
7636
diff
changeset
|
620 intptr_t value_of_loc(oop *pointer) { return cast_from_oop<intptr_t>((*pointer)); } |
0 | 621 |
622 | |
623 void DerivedPointerTable::add(oop *derived_loc, oop *base_loc) { | |
624 assert(Universe::heap()->is_in_or_null(*base_loc), "not an oop"); | |
625 assert(derived_loc != base_loc, "Base and derived in same location"); | |
626 if (_active) { | |
627 assert(*derived_loc != (oop)base_loc, "location already added"); | |
628 assert(_list != NULL, "list must exist"); | |
629 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
|
630 // This assert is invalid because derived pointers can be |
f7d55ea6ee56
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
1972
diff
changeset
|
631 // arbitrarily far away from their base. |
f7d55ea6ee56
7045514: SPARC assembly code for JSR 292 ricochet frames
never
parents:
1972
diff
changeset
|
632 // assert(offset >= -1000000, "wrong derived pointer info"); |
0 | 633 |
634 if (TraceDerivedPointers) { | |
635 tty->print_cr( | |
636 "Add derived pointer@" INTPTR_FORMAT | |
637 " - Derived: " INTPTR_FORMAT | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
12316
diff
changeset
|
638 " Base: " INTPTR_FORMAT " (@" INTPTR_FORMAT ") (Offset: " INTX_FORMAT ")", |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
12316
diff
changeset
|
639 p2i(derived_loc), p2i((address)*derived_loc), p2i((address)*base_loc), p2i(base_loc), offset |
0 | 640 ); |
641 } | |
642 // Set derived oop location to point to base. | |
643 *derived_loc = (oop)base_loc; | |
644 assert_lock_strong(DerivedPointerTableGC_lock); | |
645 DerivedPointerEntry *entry = new DerivedPointerEntry(derived_loc, offset); | |
646 _list->append(entry); | |
647 } | |
648 } | |
649 | |
650 | |
651 void DerivedPointerTable::update_pointers() { | |
652 assert(_list != NULL, "list must exist"); | |
653 for(int i = 0; i < _list->length(); i++) { | |
654 DerivedPointerEntry* entry = _list->at(i); | |
655 oop* derived_loc = entry->location(); | |
656 intptr_t offset = entry->offset(); | |
657 // The derived oop was setup to point to location of base | |
658 oop base = **(oop**)derived_loc; | |
659 assert(Universe::heap()->is_in_or_null(base), "must be an oop"); | |
660 | |
661 *derived_loc = (oop)(((address)base) + offset); | |
662 assert(value_of_loc(derived_loc) - value_of_loc(&base) == offset, "sanity check"); | |
663 | |
664 if (TraceDerivedPointers) { | |
665 tty->print_cr("Updating derived pointer@" INTPTR_FORMAT | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
12316
diff
changeset
|
666 " - Derived: " INTPTR_FORMAT " Base: " INTPTR_FORMAT " (Offset: " INTX_FORMAT ")", |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
12316
diff
changeset
|
667 p2i(derived_loc), p2i((address)*derived_loc), p2i((address)base), offset); |
0 | 668 } |
669 | |
670 // Delete entry | |
671 delete entry; | |
672 _list->at_put(i, NULL); | |
673 } | |
674 // Clear list, so it is ready for next traversal (this is an invariant) | |
675 if (TraceDerivedPointers && !_list->is_empty()) { | |
676 tty->print_cr("--------------------------"); | |
677 } | |
678 _list->clear(); | |
679 _active = false; | |
680 } | |
681 | |
22294
d86b226e331a
Enable derived oop processing by the GC with JVMCI
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21559
diff
changeset
|
682 #endif // COMPILER2 || JVMCI |