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