Mercurial > hg > graal-compiler
annotate src/share/vm/oops/klass.cpp @ 1941:79d04223b8a5
Added caching for resolved types and resolved fields.
This is crucial, because the local load elimination will lead to wrong results, if field equality (of two RiField objects with the same object and the same RiType) is not given. The caching makes sure that the default equals implementation is sufficient.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Tue, 28 Dec 2010 18:33:26 +0100 |
parents | 126ea7725993 |
children | 06f017f7daa7 |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1155
diff
changeset
|
2 * Copyright (c) 1997, 2008, 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:
1155
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1155
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:
1155
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_klass.cpp.incl" | |
27 | |
28 | |
29 bool Klass::is_subclass_of(klassOop k) const { | |
30 // Run up the super chain and check | |
31 klassOop t = as_klassOop(); | |
32 | |
33 if (t == k) return true; | |
34 t = Klass::cast(t)->super(); | |
35 | |
36 while (t != NULL) { | |
37 if (t == k) return true; | |
38 t = Klass::cast(t)->super(); | |
39 } | |
40 return false; | |
41 } | |
42 | |
43 bool Klass::search_secondary_supers(klassOop k) const { | |
44 // Put some extra logic here out-of-line, before the search proper. | |
45 // This cuts down the size of the inline method. | |
46 | |
47 // This is necessary, since I am never in my own secondary_super list. | |
48 if (this->as_klassOop() == k) | |
49 return true; | |
50 // Scan the array-of-objects for a match | |
51 int cnt = secondary_supers()->length(); | |
52 for (int i = 0; i < cnt; i++) { | |
53 if (secondary_supers()->obj_at(i) == k) { | |
54 ((Klass*)this)->set_secondary_super_cache(k); | |
55 return true; | |
56 } | |
57 } | |
58 return false; | |
59 } | |
60 | |
61 // Return self, except for abstract classes with exactly 1 | |
62 // implementor. Then return the 1 concrete implementation. | |
63 Klass *Klass::up_cast_abstract() { | |
64 Klass *r = this; | |
65 while( r->is_abstract() ) { // Receiver is abstract? | |
66 Klass *s = r->subklass(); // Check for exactly 1 subklass | |
67 if( !s || s->next_sibling() ) // Oops; wrong count; give up | |
68 return this; // Return 'this' as a no-progress flag | |
69 r = s; // Loop till find concrete class | |
70 } | |
71 return r; // Return the 1 concrete class | |
72 } | |
73 | |
605 | 74 // Find LCA in class hierarchy |
0 | 75 Klass *Klass::LCA( Klass *k2 ) { |
76 Klass *k1 = this; | |
77 while( 1 ) { | |
78 if( k1->is_subtype_of(k2->as_klassOop()) ) return k2; | |
79 if( k2->is_subtype_of(k1->as_klassOop()) ) return k1; | |
80 k1 = k1->super()->klass_part(); | |
81 k2 = k2->super()->klass_part(); | |
82 } | |
83 } | |
84 | |
85 | |
86 void Klass::check_valid_for_instantiation(bool throwError, TRAPS) { | |
87 ResourceMark rm(THREAD); | |
88 THROW_MSG(throwError ? vmSymbols::java_lang_InstantiationError() | |
89 : vmSymbols::java_lang_InstantiationException(), external_name()); | |
90 } | |
91 | |
92 | |
93 void Klass::copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS) { | |
94 THROW(vmSymbols::java_lang_ArrayStoreException()); | |
95 } | |
96 | |
97 | |
98 void Klass::initialize(TRAPS) { | |
99 ShouldNotReachHere(); | |
100 } | |
101 | |
102 bool Klass::compute_is_subtype_of(klassOop k) { | |
103 assert(k->is_klass(), "argument must be a class"); | |
104 return is_subclass_of(k); | |
105 } | |
106 | |
107 | |
108 methodOop Klass::uncached_lookup_method(symbolOop name, symbolOop signature) const { | |
109 #ifdef ASSERT | |
110 tty->print_cr("Error: uncached_lookup_method called on a klass oop." | |
111 " Likely error: reflection method does not correctly" | |
112 " wrap return value in a mirror object."); | |
113 #endif | |
114 ShouldNotReachHere(); | |
115 return NULL; | |
116 } | |
117 | |
118 klassOop Klass::base_create_klass_oop(KlassHandle& klass, int size, | |
119 const Klass_vtbl& vtbl, TRAPS) { | |
120 size = align_object_size(size); | |
121 // allocate and initialize vtable | |
122 Klass* kl = (Klass*) vtbl.allocate_permanent(klass, size, CHECK_NULL); | |
123 klassOop k = kl->as_klassOop(); | |
124 | |
125 { // Preinitialize supertype information. | |
126 // A later call to initialize_supers() may update these settings: | |
127 kl->set_super(NULL); | |
128 for (juint i = 0; i < Klass::primary_super_limit(); i++) { | |
129 kl->_primary_supers[i] = NULL; | |
130 } | |
131 kl->set_secondary_supers(NULL); | |
132 oop_store_without_check((oop*) &kl->_primary_supers[0], k); | |
133 kl->set_super_check_offset(primary_supers_offset_in_bytes() + sizeof(oopDesc)); | |
134 } | |
135 | |
136 kl->set_java_mirror(NULL); | |
1941
79d04223b8a5
Added caching for resolved types and resolved fields.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1681
diff
changeset
|
137 kl->set_c1x_mirror(NULL); |
0 | 138 kl->set_modifier_flags(0); |
139 kl->set_layout_helper(Klass::_lh_neutral_value); | |
140 kl->set_name(NULL); | |
141 AccessFlags af; | |
142 af.set_flags(0); | |
143 kl->set_access_flags(af); | |
144 kl->set_subklass(NULL); | |
145 kl->set_next_sibling(NULL); | |
146 kl->set_alloc_count(0); | |
147 kl->set_alloc_size(0); | |
148 | |
149 kl->set_prototype_header(markOopDesc::prototype()); | |
150 kl->set_biased_lock_revocation_count(0); | |
151 kl->set_last_biased_lock_bulk_revocation_time(0); | |
152 | |
153 return k; | |
154 } | |
155 | |
156 KlassHandle Klass::base_create_klass(KlassHandle& klass, int size, | |
157 const Klass_vtbl& vtbl, TRAPS) { | |
158 klassOop ek = base_create_klass_oop(klass, size, vtbl, THREAD); | |
159 return KlassHandle(THREAD, ek); | |
160 } | |
161 | |
162 void Klass_vtbl::post_new_init_klass(KlassHandle& klass, | |
163 klassOop new_klass, | |
164 int size) const { | |
165 assert(!new_klass->klass_part()->null_vtbl(), "Not a complete klass"); | |
166 CollectedHeap::post_allocation_install_obj_klass(klass, new_klass, size); | |
167 } | |
168 | |
169 void* Klass_vtbl::operator new(size_t ignored, KlassHandle& klass, | |
170 int size, TRAPS) { | |
171 // The vtable pointer is installed during the execution of | |
172 // constructors in the call to permanent_obj_allocate(). Delay | |
173 // the installation of the klass pointer into the new klass "k" | |
174 // until after the vtable pointer has been installed (i.e., until | |
175 // after the return of permanent_obj_allocate(). | |
176 klassOop k = | |
177 (klassOop) CollectedHeap::permanent_obj_allocate_no_klass_install(klass, | |
178 size, CHECK_NULL); | |
179 return k->klass_part(); | |
180 } | |
181 | |
182 jint Klass::array_layout_helper(BasicType etype) { | |
183 assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype"); | |
184 // Note that T_ARRAY is not allowed here. | |
185 int hsize = arrayOopDesc::base_offset_in_bytes(etype); | |
29
d5fc211aea19
6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
kvn
parents:
0
diff
changeset
|
186 int esize = type2aelembytes(etype); |
0 | 187 bool isobj = (etype == T_OBJECT); |
188 int tag = isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value; | |
189 int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize)); | |
190 | |
191 assert(lh < (int)_lh_neutral_value, "must look like an array layout"); | |
192 assert(layout_helper_is_javaArray(lh), "correct kind"); | |
193 assert(layout_helper_is_objArray(lh) == isobj, "correct kind"); | |
194 assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind"); | |
195 assert(layout_helper_header_size(lh) == hsize, "correct decode"); | |
196 assert(layout_helper_element_type(lh) == etype, "correct decode"); | |
197 assert(1 << layout_helper_log2_element_size(lh) == esize, "correct decode"); | |
198 | |
199 return lh; | |
200 } | |
201 | |
202 bool Klass::can_be_primary_super_slow() const { | |
203 if (super() == NULL) | |
204 return true; | |
205 else if (super()->klass_part()->super_depth() >= primary_super_limit()-1) | |
206 return false; | |
207 else | |
208 return true; | |
209 } | |
210 | |
211 void Klass::initialize_supers(klassOop k, TRAPS) { | |
212 if (FastSuperclassLimit == 0) { | |
213 // None of the other machinery matters. | |
214 set_super(k); | |
215 return; | |
216 } | |
217 if (k == NULL) { | |
218 set_super(NULL); | |
219 oop_store_without_check((oop*) &_primary_supers[0], (oop) this->as_klassOop()); | |
220 assert(super_depth() == 0, "Object must already be initialized properly"); | |
1142 | 221 } else if (k != super() || k == SystemDictionary::Object_klass()) { |
222 assert(super() == NULL || super() == SystemDictionary::Object_klass(), | |
0 | 223 "initialize this only once to a non-trivial value"); |
224 set_super(k); | |
225 Klass* sup = k->klass_part(); | |
226 int sup_depth = sup->super_depth(); | |
227 juint my_depth = MIN2(sup_depth + 1, (int)primary_super_limit()); | |
228 if (!can_be_primary_super_slow()) | |
229 my_depth = primary_super_limit(); | |
230 for (juint i = 0; i < my_depth; i++) { | |
231 oop_store_without_check((oop*) &_primary_supers[i], (oop) sup->_primary_supers[i]); | |
232 } | |
233 klassOop *super_check_cell; | |
234 if (my_depth < primary_super_limit()) { | |
235 oop_store_without_check((oop*) &_primary_supers[my_depth], (oop) this->as_klassOop()); | |
236 super_check_cell = &_primary_supers[my_depth]; | |
237 } else { | |
238 // Overflow of the primary_supers array forces me to be secondary. | |
239 super_check_cell = &_secondary_super_cache; | |
240 } | |
241 set_super_check_offset((address)super_check_cell - (address) this->as_klassOop()); | |
242 | |
243 #ifdef ASSERT | |
244 { | |
245 juint j = super_depth(); | |
246 assert(j == my_depth, "computed accessor gets right answer"); | |
247 klassOop t = as_klassOop(); | |
248 while (!Klass::cast(t)->can_be_primary_super()) { | |
249 t = Klass::cast(t)->super(); | |
250 j = Klass::cast(t)->super_depth(); | |
251 } | |
252 for (juint j1 = j+1; j1 < primary_super_limit(); j1++) { | |
253 assert(primary_super_of_depth(j1) == NULL, "super list padding"); | |
254 } | |
255 while (t != NULL) { | |
256 assert(primary_super_of_depth(j) == t, "super list initialization"); | |
257 t = Klass::cast(t)->super(); | |
258 --j; | |
259 } | |
260 assert(j == (juint)-1, "correct depth count"); | |
261 } | |
262 #endif | |
263 } | |
264 | |
265 if (secondary_supers() == NULL) { | |
266 KlassHandle this_kh (THREAD, this); | |
267 | |
268 // Now compute the list of secondary supertypes. | |
269 // Secondaries can occasionally be on the super chain, | |
270 // if the inline "_primary_supers" array overflows. | |
271 int extras = 0; | |
272 klassOop p; | |
273 for (p = super(); !(p == NULL || p->klass_part()->can_be_primary_super()); p = p->klass_part()->super()) { | |
274 ++extras; | |
275 } | |
276 | |
277 // Compute the "real" non-extra secondaries. | |
278 objArrayOop secondary_oops = compute_secondary_supers(extras, CHECK); | |
279 objArrayHandle secondaries (THREAD, secondary_oops); | |
280 | |
281 // Store the extra secondaries in the first array positions: | |
282 int fillp = extras; | |
283 for (p = this_kh->super(); !(p == NULL || p->klass_part()->can_be_primary_super()); p = p->klass_part()->super()) { | |
284 int i; // Scan for overflow primaries being duplicates of 2nd'arys | |
285 | |
286 // This happens frequently for very deeply nested arrays: the | |
287 // primary superclass chain overflows into the secondary. The | |
288 // secondary list contains the element_klass's secondaries with | |
289 // an extra array dimension added. If the element_klass's | |
290 // secondary list already contains some primary overflows, they | |
291 // (with the extra level of array-ness) will collide with the | |
292 // normal primary superclass overflows. | |
293 for( i = extras; i < secondaries->length(); i++ ) | |
294 if( secondaries->obj_at(i) == p ) | |
295 break; | |
296 if( i < secondaries->length() ) | |
297 continue; // It's a dup, don't put it in | |
298 secondaries->obj_at_put(--fillp, p); | |
299 } | |
300 // See if we had some dup's, so the array has holes in it. | |
301 if( fillp > 0 ) { | |
302 // Pack the array. Drop the old secondaries array on the floor | |
303 // and let GC reclaim it. | |
304 objArrayOop s2 = oopFactory::new_system_objArray(secondaries->length() - fillp, CHECK); | |
305 for( int i = 0; i < s2->length(); i++ ) | |
306 s2->obj_at_put( i, secondaries->obj_at(i+fillp) ); | |
307 secondaries = objArrayHandle(THREAD, s2); | |
308 } | |
309 | |
310 #ifdef ASSERT | |
311 if (secondaries() != Universe::the_array_interfaces_array()) { | |
312 // We must not copy any NULL placeholders left over from bootstrap. | |
313 for (int j = 0; j < secondaries->length(); j++) { | |
314 assert(secondaries->obj_at(j) != NULL, "correct bootstrapping order"); | |
315 } | |
316 } | |
317 #endif | |
318 | |
319 this_kh->set_secondary_supers(secondaries()); | |
320 } | |
321 } | |
322 | |
323 objArrayOop Klass::compute_secondary_supers(int num_extra_slots, TRAPS) { | |
324 assert(num_extra_slots == 0, "override for complex klasses"); | |
325 return Universe::the_empty_system_obj_array(); | |
326 } | |
327 | |
328 | |
329 Klass* Klass::subklass() const { | |
330 return _subklass == NULL ? NULL : Klass::cast(_subklass); | |
331 } | |
332 | |
333 instanceKlass* Klass::superklass() const { | |
334 assert(super() == NULL || super()->klass_part()->oop_is_instance(), "must be instance klass"); | |
335 return _super == NULL ? NULL : instanceKlass::cast(_super); | |
336 } | |
337 | |
338 Klass* Klass::next_sibling() const { | |
339 return _next_sibling == NULL ? NULL : Klass::cast(_next_sibling); | |
340 } | |
341 | |
342 void Klass::set_subklass(klassOop s) { | |
343 assert(s != as_klassOop(), "sanity check"); | |
344 oop_store_without_check((oop*)&_subklass, s); | |
345 } | |
346 | |
347 void Klass::set_next_sibling(klassOop s) { | |
348 assert(s != as_klassOop(), "sanity check"); | |
349 oop_store_without_check((oop*)&_next_sibling, s); | |
350 } | |
351 | |
352 void Klass::append_to_sibling_list() { | |
353 debug_only(if (!SharedSkipVerify) as_klassOop()->verify();) | |
354 // add ourselves to superklass' subklass list | |
355 instanceKlass* super = superklass(); | |
356 if (super == NULL) return; // special case: class Object | |
357 assert(SharedSkipVerify || | |
358 (!super->is_interface() // interfaces cannot be supers | |
359 && (super->superklass() == NULL || !is_interface())), | |
360 "an interface can only be a subklass of Object"); | |
361 klassOop prev_first_subklass = super->subklass_oop(); | |
362 if (prev_first_subklass != NULL) { | |
363 // set our sibling to be the superklass' previous first subklass | |
364 set_next_sibling(prev_first_subklass); | |
365 } | |
366 // make ourselves the superklass' first subklass | |
367 super->set_subklass(as_klassOop()); | |
368 debug_only(if (!SharedSkipVerify) as_klassOop()->verify();) | |
369 } | |
370 | |
371 void Klass::remove_from_sibling_list() { | |
372 // remove receiver from sibling list | |
373 instanceKlass* super = superklass(); | |
1142 | 374 assert(super != NULL || as_klassOop() == SystemDictionary::Object_klass(), "should have super"); |
0 | 375 if (super == NULL) return; // special case: class Object |
376 if (super->subklass() == this) { | |
377 // first subklass | |
378 super->set_subklass(_next_sibling); | |
379 } else { | |
380 Klass* sib = super->subklass(); | |
381 while (sib->next_sibling() != this) { | |
382 sib = sib->next_sibling(); | |
383 }; | |
384 sib->set_next_sibling(_next_sibling); | |
385 } | |
386 } | |
387 | |
388 void Klass::follow_weak_klass_links( BoolObjectClosure* is_alive, OopClosure* keep_alive) { | |
389 // This klass is alive but the subklass and siblings are not followed/updated. | |
390 // We update the subklass link and the subklass' sibling links here. | |
391 // Our own sibling link will be updated by our superclass (which must be alive | |
392 // since we are). | |
393 assert(is_alive->do_object_b(as_klassOop()), "just checking, this should be live"); | |
394 if (ClassUnloading) { | |
395 klassOop sub = subklass_oop(); | |
396 if (sub != NULL && !is_alive->do_object_b(sub)) { | |
397 // first subklass not alive, find first one alive | |
398 do { | |
399 #ifndef PRODUCT | |
400 if (TraceClassUnloading && WizardMode) { | |
401 ResourceMark rm; | |
402 tty->print_cr("[Unlinking class (subclass) %s]", sub->klass_part()->external_name()); | |
403 } | |
404 #endif | |
405 sub = sub->klass_part()->next_sibling_oop(); | |
406 } while (sub != NULL && !is_alive->do_object_b(sub)); | |
407 set_subklass(sub); | |
408 } | |
409 // now update the subklass' sibling list | |
410 while (sub != NULL) { | |
411 klassOop next = sub->klass_part()->next_sibling_oop(); | |
412 if (next != NULL && !is_alive->do_object_b(next)) { | |
413 // first sibling not alive, find first one alive | |
414 do { | |
415 #ifndef PRODUCT | |
416 if (TraceClassUnloading && WizardMode) { | |
417 ResourceMark rm; | |
418 tty->print_cr("[Unlinking class (sibling) %s]", next->klass_part()->external_name()); | |
419 } | |
420 #endif | |
421 next = next->klass_part()->next_sibling_oop(); | |
422 } while (next != NULL && !is_alive->do_object_b(next)); | |
423 sub->klass_part()->set_next_sibling(next); | |
424 } | |
425 sub = next; | |
426 } | |
427 } else { | |
428 // Always follow subklass and sibling link. This will prevent any klasses from | |
429 // being unloaded (all classes are transitively linked from java.lang.Object). | |
430 keep_alive->do_oop(adr_subklass()); | |
431 keep_alive->do_oop(adr_next_sibling()); | |
432 } | |
433 } | |
434 | |
435 | |
436 void Klass::remove_unshareable_info() { | |
437 if (oop_is_instance()) { | |
438 instanceKlass* ik = (instanceKlass*)this; | |
439 if (ik->is_linked()) { | |
440 ik->unlink_class(); | |
441 } | |
442 } | |
443 set_subklass(NULL); | |
444 set_next_sibling(NULL); | |
445 } | |
446 | |
447 | |
448 klassOop Klass::array_klass_or_null(int rank) { | |
449 EXCEPTION_MARK; | |
450 // No exception can be thrown by array_klass_impl when called with or_null == true. | |
451 // (In anycase, the execption mark will fail if it do so) | |
452 return array_klass_impl(true, rank, THREAD); | |
453 } | |
454 | |
455 | |
456 klassOop Klass::array_klass_or_null() { | |
457 EXCEPTION_MARK; | |
458 // No exception can be thrown by array_klass_impl when called with or_null == true. | |
459 // (In anycase, the execption mark will fail if it do so) | |
460 return array_klass_impl(true, THREAD); | |
461 } | |
462 | |
463 | |
464 klassOop Klass::array_klass_impl(bool or_null, int rank, TRAPS) { | |
465 fatal("array_klass should be dispatched to instanceKlass, objArrayKlass or typeArrayKlass"); | |
466 return NULL; | |
467 } | |
468 | |
469 | |
470 klassOop Klass::array_klass_impl(bool or_null, TRAPS) { | |
471 fatal("array_klass should be dispatched to instanceKlass, objArrayKlass or typeArrayKlass"); | |
472 return NULL; | |
473 } | |
474 | |
475 | |
476 void Klass::with_array_klasses_do(void f(klassOop k)) { | |
477 f(as_klassOop()); | |
478 } | |
479 | |
480 | |
481 const char* Klass::external_name() const { | |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
482 if (oop_is_instance()) { |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
483 instanceKlass* ik = (instanceKlass*) this; |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
484 if (ik->is_anonymous()) { |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
485 assert(AnonymousClasses, ""); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
486 intptr_t hash = ik->java_mirror()->identity_hash(); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
487 char hash_buf[40]; |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
488 sprintf(hash_buf, "/" UINTX_FORMAT, (uintx)hash); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
489 size_t hash_len = strlen(hash_buf); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
490 |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
491 size_t result_len = name()->utf8_length(); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
492 char* result = NEW_RESOURCE_ARRAY(char, result_len + hash_len + 1); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
493 name()->as_klass_external_name(result, (int) result_len + 1); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
494 assert(strlen(result) == result_len, ""); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
495 strcpy(result + result_len, hash_buf); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
496 assert(strlen(result) == result_len + hash_len, ""); |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
497 return result; |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
498 } |
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
499 } |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
605
diff
changeset
|
500 if (name() == NULL) return "<unknown>"; |
0 | 501 return name()->as_klass_external_name(); |
502 } | |
503 | |
504 | |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
605
diff
changeset
|
505 const char* Klass::signature_name() const { |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
605
diff
changeset
|
506 if (name() == NULL) return "<unknown>"; |
0 | 507 return name()->as_C_string(); |
508 } | |
509 | |
510 // Unless overridden, modifier_flags is 0. | |
511 jint Klass::compute_modifier_flags(TRAPS) const { | |
512 return 0; | |
513 } | |
514 | |
515 int Klass::atomic_incr_biased_lock_revocation_count() { | |
516 return (int) Atomic::add(1, &_biased_lock_revocation_count); | |
517 } | |
518 | |
519 // Unless overridden, jvmti_class_status has no flags set. | |
520 jint Klass::jvmti_class_status() const { | |
521 return 0; | |
522 } | |
523 | |
524 // Printing | |
525 | |
526 void Klass::oop_print_on(oop obj, outputStream* st) { | |
527 ResourceMark rm; | |
528 // print title | |
529 st->print_cr("%s ", internal_name()); | |
530 obj->print_address_on(st); | |
531 | |
532 if (WizardMode) { | |
533 // print header | |
534 obj->mark()->print_on(st); | |
535 } | |
536 | |
537 // print class | |
538 st->print(" - klass: "); | |
539 obj->klass()->print_value_on(st); | |
540 st->cr(); | |
541 } | |
542 | |
543 void Klass::oop_print_value_on(oop obj, outputStream* st) { | |
544 // print title | |
545 ResourceMark rm; // Cannot print in debug mode without this | |
546 st->print("%s", internal_name()); | |
547 obj->print_address_on(st); | |
548 } | |
549 | |
550 // Verification | |
551 | |
552 void Klass::oop_verify_on(oop obj, outputStream* st) { | |
553 guarantee(obj->is_oop(), "should be oop"); | |
554 guarantee(obj->klass()->is_perm(), "should be in permspace"); | |
555 guarantee(obj->klass()->is_klass(), "klass field is not a klass"); | |
556 } | |
557 | |
558 | |
559 void Klass::oop_verify_old_oop(oop obj, oop* p, bool allow_dirty) { | |
560 /* $$$ I think this functionality should be handled by verification of | |
561 RememberedSet::verify_old_oop(obj, p, allow_dirty, false); | |
562 the card table. */ | |
563 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
29
diff
changeset
|
564 void Klass::oop_verify_old_oop(oop obj, narrowOop* p, bool allow_dirty) { } |
0 | 565 |
566 #ifndef PRODUCT | |
567 | |
568 void Klass::verify_vtable_index(int i) { | |
569 assert(oop_is_instance() || oop_is_array(), "only instanceKlass and arrayKlass have vtables"); | |
570 if (oop_is_instance()) { | |
571 assert(i>=0 && i<((instanceKlass*)this)->vtable_length()/vtableEntry::size(), "index out of bounds"); | |
572 } else { | |
573 assert(i>=0 && i<((arrayKlass*)this)->vtable_length()/vtableEntry::size(), "index out of bounds"); | |
574 } | |
575 } | |
576 | |
577 #endif |