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