59 int &num_miranda_methods, |
59 int &num_miranda_methods, |
60 klassOop super, |
60 klassOop super, |
61 objArrayOop methods, |
61 objArrayOop methods, |
62 AccessFlags class_flags, |
62 AccessFlags class_flags, |
63 Handle classloader, |
63 Handle classloader, |
64 symbolHandle classname, |
64 Symbol* classname, |
65 objArrayOop local_interfaces, |
65 objArrayOop local_interfaces, |
66 TRAPS |
66 TRAPS |
67 ) { |
67 ) { |
68 |
68 |
69 No_Safepoint_Verifier nsv; |
69 No_Safepoint_Verifier nsv; |
208 // Called for cases where a method does not override its superclass' vtable entry |
208 // Called for cases where a method does not override its superclass' vtable entry |
209 // For bytecodes not produced by javac together it is possible that a method does not override |
209 // For bytecodes not produced by javac together it is possible that a method does not override |
210 // the superclass's method, but might indirectly override a super-super class's vtable entry |
210 // the superclass's method, but might indirectly override a super-super class's vtable entry |
211 // If none found, return a null superk, else return the superk of the method this does override |
211 // If none found, return a null superk, else return the superk of the method this does override |
212 instanceKlass* klassVtable::find_transitive_override(instanceKlass* initialsuper, methodHandle target_method, |
212 instanceKlass* klassVtable::find_transitive_override(instanceKlass* initialsuper, methodHandle target_method, |
213 int vtable_index, Handle target_loader, symbolHandle target_classname, Thread * THREAD) { |
213 int vtable_index, Handle target_loader, Symbol* target_classname, Thread * THREAD) { |
214 instanceKlass* superk = initialsuper; |
214 instanceKlass* superk = initialsuper; |
215 while (superk != NULL && superk->super() != NULL) { |
215 while (superk != NULL && superk->super() != NULL) { |
216 instanceKlass* supersuperklass = instanceKlass::cast(superk->super()); |
216 instanceKlass* supersuperklass = instanceKlass::cast(superk->super()); |
217 klassVtable* ssVtable = supersuperklass->vtable(); |
217 klassVtable* ssVtable = supersuperklass->vtable(); |
218 if (vtable_index < ssVtable->length()) { |
218 if (vtable_index < ssVtable->length()) { |
219 methodOop super_method = ssVtable->method_at(vtable_index); |
219 methodOop super_method = ssVtable->method_at(vtable_index); |
220 #ifndef PRODUCT |
220 #ifndef PRODUCT |
221 symbolHandle name(THREAD,target_method()->name()); |
221 Symbol* name= target_method()->name(); |
222 symbolHandle signature(THREAD,target_method()->signature()); |
222 Symbol* signature = target_method()->signature(); |
223 assert(super_method->name() == name() && super_method->signature() == signature(), "vtable entry name/sig mismatch"); |
223 assert(super_method->name() == name && super_method->signature() == signature, "vtable entry name/sig mismatch"); |
224 #endif |
224 #endif |
225 if (supersuperklass->is_override(super_method, target_loader, target_classname, THREAD)) { |
225 if (supersuperklass->is_override(super_method, target_loader, target_classname, THREAD)) { |
226 #ifndef PRODUCT |
226 #ifndef PRODUCT |
227 if (PrintVtables && Verbose) { |
227 if (PrintVtables && Verbose) { |
228 ResourceMark rm(THREAD); |
228 ResourceMark rm(THREAD); |
292 // search through the vtable and update overridden entries |
292 // search through the vtable and update overridden entries |
293 // Since check_signature_loaders acquires SystemDictionary_lock |
293 // Since check_signature_loaders acquires SystemDictionary_lock |
294 // which can block for gc, once we are in this loop, use handles |
294 // which can block for gc, once we are in this loop, use handles |
295 // For classfiles built with >= jdk7, we now look for transitive overrides |
295 // For classfiles built with >= jdk7, we now look for transitive overrides |
296 |
296 |
297 symbolHandle name(THREAD,target_method()->name()); |
297 Symbol* name = target_method()->name(); |
298 symbolHandle signature(THREAD,target_method()->signature()); |
298 Symbol* signature = target_method()->signature(); |
299 Handle target_loader(THREAD, _klass->class_loader()); |
299 Handle target_loader(THREAD, _klass->class_loader()); |
300 symbolHandle target_classname(THREAD, _klass->name()); |
300 Symbol* target_classname = _klass->name(); |
301 for(int i = 0; i < super_vtable_len; i++) { |
301 for(int i = 0; i < super_vtable_len; i++) { |
302 methodOop super_method = method_at(i); |
302 methodOop super_method = method_at(i); |
303 // Check if method name matches |
303 // Check if method name matches |
304 if (super_method->name() == name() && super_method->signature() == signature()) { |
304 if (super_method->name() == name && super_method->signature() == signature) { |
305 |
305 |
306 // get super_klass for method_holder for the found method |
306 // get super_klass for method_holder for the found method |
307 instanceKlass* super_klass = instanceKlass::cast(super_method->method_holder()); |
307 instanceKlass* super_klass = instanceKlass::cast(super_method->method_holder()); |
308 |
308 |
309 if ((super_klass->is_override(super_method, target_loader, target_classname, THREAD)) || |
309 if ((super_klass->is_override(super_method, target_loader, target_classname, THREAD)) || |
404 // However, the vtable entries are filled in at link time, and therefore |
404 // However, the vtable entries are filled in at link time, and therefore |
405 // the superclass' vtable may not yet have been filled in. |
405 // the superclass' vtable may not yet have been filled in. |
406 bool klassVtable::needs_new_vtable_entry(methodHandle target_method, |
406 bool klassVtable::needs_new_vtable_entry(methodHandle target_method, |
407 klassOop super, |
407 klassOop super, |
408 Handle classloader, |
408 Handle classloader, |
409 symbolHandle classname, |
409 Symbol* classname, |
410 AccessFlags class_flags, |
410 AccessFlags class_flags, |
411 TRAPS) { |
411 TRAPS) { |
412 if ((class_flags.is_final() || target_method()->is_final()) || |
412 if ((class_flags.is_final() || target_method()->is_final()) || |
413 // a final method never needs a new entry; final methods can be statically |
413 // a final method never needs a new entry; final methods can be statically |
414 // resolved and they have to be present in the vtable only if they override |
414 // resolved and they have to be present in the vtable only if they override |
434 } |
434 } |
435 |
435 |
436 // search through the super class hierarchy to see if we need |
436 // search through the super class hierarchy to see if we need |
437 // a new entry |
437 // a new entry |
438 ResourceMark rm; |
438 ResourceMark rm; |
439 symbolOop name = target_method()->name(); |
439 Symbol* name = target_method()->name(); |
440 symbolOop signature = target_method()->signature(); |
440 Symbol* signature = target_method()->signature(); |
441 klassOop k = super; |
441 klassOop k = super; |
442 methodOop super_method = NULL; |
442 methodOop super_method = NULL; |
443 instanceKlass *holder = NULL; |
443 instanceKlass *holder = NULL; |
444 methodOop recheck_method = NULL; |
444 methodOop recheck_method = NULL; |
445 while (k != NULL) { |
445 while (k != NULL) { |
483 } |
483 } |
484 |
484 |
485 // Support for miranda methods |
485 // Support for miranda methods |
486 |
486 |
487 // get the vtable index of a miranda method with matching "name" and "signature" |
487 // get the vtable index of a miranda method with matching "name" and "signature" |
488 int klassVtable::index_of_miranda(symbolOop name, symbolOop signature) { |
488 int klassVtable::index_of_miranda(Symbol* name, Symbol* signature) { |
489 // search from the bottom, might be faster |
489 // search from the bottom, might be faster |
490 for (int i = (length() - 1); i >= 0; i--) { |
490 for (int i = (length() - 1); i >= 0; i--) { |
491 methodOop m = table()[i].method(); |
491 methodOop m = table()[i].method(); |
492 if (is_miranda_entry_at(i) && |
492 if (is_miranda_entry_at(i) && |
493 m->name() == name && m->signature() == signature) { |
493 m->name() == name && m->signature() == signature) { |
514 } |
514 } |
515 |
515 |
516 // check if a method is a miranda method, given a class's methods table and it's super |
516 // check if a method is a miranda method, given a class's methods table and it's super |
517 // the caller must make sure that the method belongs to an interface implemented by the class |
517 // the caller must make sure that the method belongs to an interface implemented by the class |
518 bool klassVtable::is_miranda(methodOop m, objArrayOop class_methods, klassOop super) { |
518 bool klassVtable::is_miranda(methodOop m, objArrayOop class_methods, klassOop super) { |
519 symbolOop name = m->name(); |
519 Symbol* name = m->name(); |
520 symbolOop signature = m->signature(); |
520 Symbol* signature = m->signature(); |
521 |
|
522 if (instanceKlass::find_method(class_methods, name, signature) == NULL) { |
521 if (instanceKlass::find_method(class_methods, name, signature) == NULL) { |
523 // did not find it in the method table of the current class |
522 // did not find it in the method table of the current class |
524 if (super == NULL) { |
523 if (super == NULL) { |
525 // super doesn't exist |
524 // super doesn't exist |
526 return true; |
525 return true; |
927 // m, method_name, method_signature, klass reset each loop so they |
926 // m, method_name, method_signature, klass reset each loop so they |
928 // don't need preserving across check_signature_loaders call |
927 // don't need preserving across check_signature_loaders call |
929 // methods needs a handle in case of gc from check_signature_loaders |
928 // methods needs a handle in case of gc from check_signature_loaders |
930 for(; i < nof_methods; i++) { |
929 for(; i < nof_methods; i++) { |
931 methodOop m = (methodOop)methods()->obj_at(i); |
930 methodOop m = (methodOop)methods()->obj_at(i); |
932 symbolOop method_name = m->name(); |
931 Symbol* method_name = m->name(); |
933 symbolOop method_signature = m->signature(); |
932 Symbol* method_signature = m->signature(); |
934 |
933 |
935 // This is same code as in Linkresolver::lookup_instance_method_in_klasses |
934 // This is same code as in Linkresolver::lookup_instance_method_in_klasses |
936 methodOop target = klass->uncached_lookup_method(method_name, method_signature); |
935 methodOop target = klass->uncached_lookup_method(method_name, method_signature); |
937 while (target != NULL && target->is_static()) { |
936 while (target != NULL && target->is_static()) { |
938 // continue with recursive lookup through the superclass |
937 // continue with recursive lookup through the superclass |