247 assert(j == my_depth, "computed accessor gets right answer");
248 Klass* t = this;
249 while (!t->can_be_primary_super()) {
250 t = t->super();
251 j = t->super_depth();
252 }
253 for (juint j1 = j+1; j1 < primary_super_limit(); j1++) {
254 assert(primary_super_of_depth(j1) == NULL, "super list padding");
255 }
256 while (t != NULL) {
257 assert(primary_super_of_depth(j) == t, "super list initialization");
258 t = t->super();
259 --j;
260 }
261 assert(j == (juint)-1, "correct depth count");
262 }
263 #endif
264 }
265
266 if (secondary_supers() == NULL) {
267 KlassHandle this_kh (THREAD, this);
268
269 // Now compute the list of secondary supertypes.
270 // Secondaries can occasionally be on the super chain,
271 // if the inline "_primary_supers" array overflows.
272 int extras = 0;
273 Klass* p;
274 for (p = super(); !(p == NULL || p->can_be_primary_super()); p = p->super()) {
275 ++extras;
276 }
277
278 ResourceMark rm(THREAD); // need to reclaim GrowableArrays allocated below
279
280 // Compute the "real" non-extra secondaries.
281 GrowableArray<Klass*>* secondaries = compute_secondary_supers(extras);
282 if (secondaries == NULL) {
283 // secondary_supers set by compute_secondary_supers
284 return;
285 }
286
287 GrowableArray<Klass*>* primaries = new GrowableArray<Klass*>(extras);
288
289 for (p = this_kh->super(); !(p == NULL || p->can_be_primary_super()); p = p->super()) {
290 int i; // Scan for overflow primaries being duplicates of 2nd'arys
291
292 // This happens frequently for very deeply nested arrays: the
293 // primary superclass chain overflows into the secondary. The
294 // secondary list contains the element_klass's secondaries with
295 // an extra array dimension added. If the element_klass's
296 // secondary list already contains some primary overflows, they
297 // (with the extra level of array-ness) will collide with the
298 // normal primary superclass overflows.
299 for( i = 0; i < secondaries->length(); i++ ) {
300 if( secondaries->at(i) == p )
301 break;
302 }
303 if( i < secondaries->length() )
304 continue; // It's a dup, don't put it in
305 primaries->push(p);
306 }
307 // Combine the two arrays into a metadata object to pack the array.
308 // The primaries are added in the reverse order, then the secondaries.
309 int new_length = primaries->length() + secondaries->length();
310 Array<Klass*>* s2 = MetadataFactory::new_array<Klass*>(
311 class_loader_data(), new_length, CHECK);
312 int fill_p = primaries->length();
313 for (int j = 0; j < fill_p; j++) {
314 s2->at_put(j, primaries->pop()); // add primaries in reverse order.
315 }
316 for( int j = 0; j < secondaries->length(); j++ ) {
317 s2->at_put(j+fill_p, secondaries->at(j)); // add secondaries on the end.
318 }
319
320 #ifdef ASSERT
321 // We must not copy any NULL placeholders left over from bootstrap.
322 for (int j = 0; j < s2->length(); j++) {
323 assert(s2->at(j) != NULL, "correct bootstrapping order");
324 }
325 #endif
326
327 this_kh->set_secondary_supers(s2);
328 }
329 }
330
331 GrowableArray<Klass*>* Klass::compute_secondary_supers(int num_extra_slots) {
332 assert(num_extra_slots == 0, "override for complex klasses");
333 set_secondary_supers(Universe::the_empty_klass_array());
334 return NULL;
335 }
336
337
338 InstanceKlass* Klass::superklass() const {
339 assert(super() == NULL || super()->is_instance_klass(), "must be instance klass");
340 return _super == NULL ? NULL : InstanceKlass::cast(_super);
341 }
342
343 void Klass::set_subklass(Klass* s) {
344 assert(s != this, "sanity check");
345 _subklass = s;
346 }
347
680 guarantee(ko->is_klass(), "should be klass");
681 }
682 for ( uint i = 0; i < primary_super_limit(); i++ ) {
683 Klass* ko = _primary_supers[i];
684 if (ko != NULL) {
685 guarantee(ko->is_klass(), "should be klass");
686 }
687 }
688
689 if (java_mirror() != NULL) {
690 guarantee(java_mirror()->is_oop(), "should be instance");
691 }
692 }
693
694 void Klass::oop_verify_on(oop obj, outputStream* st) {
695 guarantee(obj->is_oop(), "should be oop");
696 guarantee(obj->klass()->is_klass(), "klass field is not a klass");
697 }
698
699 klassVtable* Klass::vtable() const {
700 return new klassVtable(this, start_of_vtable(), vtable_length() / vtableEntry::size());
701 }
702
703 vtableEntry* Klass::start_of_vtable() const {
704 return (vtableEntry*) ((address)this + in_bytes(vtable_start_offset()));
705 }
706
707 Method* Klass::method_at_vtable(int index) {
708 #ifndef PRODUCT
709 assert(index >= 0, "valid vtable index");
710 if (DebugVtables) {
711 verify_vtable_index(index);
712 }
713 #endif
714 return start_of_vtable()[index].method();
715 }
716
717 ByteSize Klass::vtable_start_offset() {
718 return in_ByteSize(InstanceKlass::header_size() * wordSize);
719 }
720
|
247 assert(j == my_depth, "computed accessor gets right answer");
248 Klass* t = this;
249 while (!t->can_be_primary_super()) {
250 t = t->super();
251 j = t->super_depth();
252 }
253 for (juint j1 = j+1; j1 < primary_super_limit(); j1++) {
254 assert(primary_super_of_depth(j1) == NULL, "super list padding");
255 }
256 while (t != NULL) {
257 assert(primary_super_of_depth(j) == t, "super list initialization");
258 t = t->super();
259 --j;
260 }
261 assert(j == (juint)-1, "correct depth count");
262 }
263 #endif
264 }
265
266 if (secondary_supers() == NULL) {
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 Klass* p;
273 for (p = super(); !(p == NULL || p->can_be_primary_super()); p = p->super()) {
274 ++extras;
275 }
276
277 ResourceMark rm(THREAD); // need to reclaim GrowableArrays allocated below
278
279 // Compute the "real" non-extra secondaries.
280 GrowableArray<Klass*>* secondaries = compute_secondary_supers(extras);
281 if (secondaries == NULL) {
282 // secondary_supers set by compute_secondary_supers
283 return;
284 }
285
286 GrowableArray<Klass*>* primaries = new GrowableArray<Klass*>(extras);
287
288 for (p = super(); !(p == NULL || p->can_be_primary_super()); p = p->super()) {
289 int i; // Scan for overflow primaries being duplicates of 2nd'arys
290
291 // This happens frequently for very deeply nested arrays: the
292 // primary superclass chain overflows into the secondary. The
293 // secondary list contains the element_klass's secondaries with
294 // an extra array dimension added. If the element_klass's
295 // secondary list already contains some primary overflows, they
296 // (with the extra level of array-ness) will collide with the
297 // normal primary superclass overflows.
298 for( i = 0; i < secondaries->length(); i++ ) {
299 if( secondaries->at(i) == p )
300 break;
301 }
302 if( i < secondaries->length() )
303 continue; // It's a dup, don't put it in
304 primaries->push(p);
305 }
306 // Combine the two arrays into a metadata object to pack the array.
307 // The primaries are added in the reverse order, then the secondaries.
308 int new_length = primaries->length() + secondaries->length();
309 Array<Klass*>* s2 = MetadataFactory::new_array<Klass*>(
310 class_loader_data(), new_length, CHECK);
311 int fill_p = primaries->length();
312 for (int j = 0; j < fill_p; j++) {
313 s2->at_put(j, primaries->pop()); // add primaries in reverse order.
314 }
315 for( int j = 0; j < secondaries->length(); j++ ) {
316 s2->at_put(j+fill_p, secondaries->at(j)); // add secondaries on the end.
317 }
318
319 #ifdef ASSERT
320 // We must not copy any NULL placeholders left over from bootstrap.
321 for (int j = 0; j < s2->length(); j++) {
322 assert(s2->at(j) != NULL, "correct bootstrapping order");
323 }
324 #endif
325
326 set_secondary_supers(s2);
327 }
328 }
329
330 GrowableArray<Klass*>* Klass::compute_secondary_supers(int num_extra_slots) {
331 assert(num_extra_slots == 0, "override for complex klasses");
332 set_secondary_supers(Universe::the_empty_klass_array());
333 return NULL;
334 }
335
336
337 InstanceKlass* Klass::superklass() const {
338 assert(super() == NULL || super()->is_instance_klass(), "must be instance klass");
339 return _super == NULL ? NULL : InstanceKlass::cast(_super);
340 }
341
342 void Klass::set_subklass(Klass* s) {
343 assert(s != this, "sanity check");
344 _subklass = s;
345 }
346
679 guarantee(ko->is_klass(), "should be klass");
680 }
681 for ( uint i = 0; i < primary_super_limit(); i++ ) {
682 Klass* ko = _primary_supers[i];
683 if (ko != NULL) {
684 guarantee(ko->is_klass(), "should be klass");
685 }
686 }
687
688 if (java_mirror() != NULL) {
689 guarantee(java_mirror()->is_oop(), "should be instance");
690 }
691 }
692
693 void Klass::oop_verify_on(oop obj, outputStream* st) {
694 guarantee(obj->is_oop(), "should be oop");
695 guarantee(obj->klass()->is_klass(), "klass field is not a klass");
696 }
697
698 klassVtable* Klass::vtable() const {
699 return new klassVtable(const_cast<Klass*>(this), start_of_vtable(), vtable_length() / vtableEntry::size());
700 }
701
702 vtableEntry* Klass::start_of_vtable() const {
703 return (vtableEntry*) ((address)this + in_bytes(vtable_start_offset()));
704 }
705
706 Method* Klass::method_at_vtable(int index) {
707 #ifndef PRODUCT
708 assert(index >= 0, "valid vtable index");
709 if (DebugVtables) {
710 verify_vtable_index(index);
711 }
712 #endif
713 return start_of_vtable()[index].method();
714 }
715
716 ByteSize Klass::vtable_start_offset() {
717 return in_ByteSize(InstanceKlass::header_size() * wordSize);
718 }
719
|