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