src/share/vm/code/dependencies.cpp

Print this page




 865 }
 866 #else
 867 #define count_find_witness_calls() (0)
 868 #endif //PRODUCT
 869 
 870 
 871 klassOop ClassHierarchyWalker::find_witness_in(DepChange& changes,
 872                                                klassOop context_type,
 873                                                bool participants_hide_witnesses) {
 874   assert(changes.involves_context(context_type), "irrelevant dependency");
 875   klassOop new_type = changes.new_type();
 876 
 877   count_find_witness_calls();
 878   NOT_PRODUCT(deps_find_witness_singles++);
 879 
 880   // Current thread must be in VM (not native mode, as in CI):
 881   assert(must_be_in_vm(), "raw oops here");
 882   // Must not move the class hierarchy during this check:
 883   assert_locked_or_safepoint(Compile_lock);
 884 








 885   assert(!is_participant(new_type), "only old classes are participants");
 886   if (participants_hide_witnesses) {
 887     // If the new type is a subtype of a participant, we are done.
 888     for (int i = 0; i < num_participants(); i++) {
 889       klassOop part = participant(i);
 890       if (part == NULL)  continue;
 891       assert(changes.involves_context(part) == Klass::cast(new_type)->is_subtype_of(part),
 892              "correct marking of participants, b/c new_type is unique");
 893       if (changes.involves_context(part)) {
 894         // new guy is protected from this check by previous participant
 895         return NULL;
 896       }
 897     }
 898   }
 899 
 900   if (is_witness(new_type) &&
 901       !ignore_witness(new_type)) {
 902     return new_type;
 903   }
 904 




 865 }
 866 #else
 867 #define count_find_witness_calls() (0)
 868 #endif //PRODUCT
 869 
 870 
 871 klassOop ClassHierarchyWalker::find_witness_in(DepChange& changes,
 872                                                klassOop context_type,
 873                                                bool participants_hide_witnesses) {
 874   assert(changes.involves_context(context_type), "irrelevant dependency");
 875   klassOop new_type = changes.new_type();
 876 
 877   count_find_witness_calls();
 878   NOT_PRODUCT(deps_find_witness_singles++);
 879 
 880   // Current thread must be in VM (not native mode, as in CI):
 881   assert(must_be_in_vm(), "raw oops here");
 882   // Must not move the class hierarchy during this check:
 883   assert_locked_or_safepoint(Compile_lock);
 884 
 885   int nof_impls = instanceKlass::cast(context_type)->nof_implementors();
 886   if (nof_impls > 1) {
 887     // Avoid this case: *I.m > { A.m, C }; B.m > C
 888     // %%% Until this is fixed more systematically, bail out.
 889     // See corresponding comment in find_witness_anywhere.
 890     return context_type;
 891   }
 892 
 893   assert(!is_participant(new_type), "only old classes are participants");
 894   if (participants_hide_witnesses) {
 895     // If the new type is a subtype of a participant, we are done.
 896     for (int i = 0; i < num_participants(); i++) {
 897       klassOop part = participant(i);
 898       if (part == NULL)  continue;
 899       assert(changes.involves_context(part) == Klass::cast(new_type)->is_subtype_of(part),
 900              "correct marking of participants, b/c new_type is unique");
 901       if (changes.involves_context(part)) {
 902         // new guy is protected from this check by previous participant
 903         return NULL;
 904       }
 905     }
 906   }
 907 
 908   if (is_witness(new_type) &&
 909       !ignore_witness(new_type)) {
 910     return new_type;
 911   }
 912