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