src/share/vm/code/dependencies.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File JDK-8034839 Sdiff src/share/vm/code

src/share/vm/code/dependencies.cpp

Print this page




 708     }
 709   }
 710 
 711   // Some dependencies are using the klass of the first object
 712   // argument as implicit context type (e.g. call_site_target_value).
 713   {
 714     int ctxkj = dep_implicit_context_arg(type());
 715     if (ctxkj >= 0) {
 716       Klass* k = argument_oop(ctxkj)->klass();
 717       assert(k != NULL && k->is_klass(), "type check");
 718       return (Klass*) k;
 719     }
 720   }
 721 
 722   // And some dependencies don't have a context type at all,
 723   // e.g. evol_method.
 724   return NULL;
 725 }
 726 
 727 // ----------------- DependencySignature --------------------------------------
 728 bool DependencySignature::equals(const DependencySignature& sig) const {
 729   if (type() != sig.type()) {
 730     return false;
 731   }
 732 
 733   if (args_count() != sig.args_count()) {

 734     return false;
 735   }
 736 
 737   for (int i = 0; i < sig.args_count(); i++) {
 738     if (arg(i) != sig.arg(i)) {
 739       return false;
 740     }
 741   }
 742   return true;
 743 }
 744 
 745 
 746 // ----------------- DependencySignatureBuffer --------------------------------------
 747 DependencySignatureBuffer::DependencySignatureBuffer() {
 748   _signatures = NEW_RESOURCE_ARRAY(GrowableArray<DependencySignature*>*, Dependencies::TYPE_LIMIT);
 749   memset(_signatures, 0, sizeof(DependencySignature*) * Dependencies::TYPE_LIMIT);
 750 }
 751 
 752 /* Check if arguments are identical. Two dependency signatures are considered
 753  * identical, if the type as well as all argument identifiers are identical.
 754  * If the dependency has not already been checked, the dependency signature is
 755  * added to the checked dependencies of the same type. The function returns
 756  * false, which causes the dependency to be checked in the caller.
 757  */
 758 bool DependencySignatureBuffer::add_if_missing(const DependencySignature& sig) {
 759   const int index = sig.type();
 760   GrowableArray<DependencySignature*>* buffer = _signatures[index];
 761   if (buffer == NULL) {
 762     buffer = new GrowableArray<DependencySignature*>();
 763     _signatures[index] = buffer;
 764   }
 765 
 766   // Check if we have already checked the dependency
 767   for (int i = 0; i < buffer->length(); i++) {
 768     DependencySignature* checked_signature = buffer->at(i);
 769     if (checked_signature->equals(sig)) {
 770       return true;
 771     }
 772   }
 773   buffer->append((DependencySignature*)&sig);
 774   return false;
 775 }
 776 
 777 
 778 /// Checking dependencies:
 779 
 780 // This hierarchy walker inspects subtypes of a given type,
 781 // trying to find a "bad" class which breaks a dependency.
 782 // Such a class is called a "witness" to the broken dependency.
 783 // While searching around, we ignore "participants", which
 784 // are already known to the dependency.
 785 class ClassHierarchyWalker {
 786  public:
 787   enum { PARTICIPANT_LIMIT = 3 };
 788 
 789  private:
 790   // optional method descriptor to check for:
 791   Symbol* _name;
 792   Symbol* _signature;
 793 
 794   // special classes which are not allowed to be witnesses:




 708     }
 709   }
 710 
 711   // Some dependencies are using the klass of the first object
 712   // argument as implicit context type (e.g. call_site_target_value).
 713   {
 714     int ctxkj = dep_implicit_context_arg(type());
 715     if (ctxkj >= 0) {
 716       Klass* k = argument_oop(ctxkj)->klass();
 717       assert(k != NULL && k->is_klass(), "type check");
 718       return (Klass*) k;
 719     }
 720   }
 721 
 722   // And some dependencies don't have a context type at all,
 723   // e.g. evol_method.
 724   return NULL;
 725 }
 726 
 727 // ----------------- DependencySignature --------------------------------------
 728 bool DependencySignature::equals(DependencySignature* sig) const {
 729   if ((type() != sig->type()) || (args_count() != sig->args_count())) {
 730     return false;
 731   }
 732 
 733   for (int i = 0; i < sig->args_count(); i++) {
 734     if (arg(i) != sig->arg(i)) {
 735       return false;
 736     }




























 737   }





 738   return true;




 739 }
 740 
 741 
 742 /// Checking dependencies:
 743 
 744 // This hierarchy walker inspects subtypes of a given type,
 745 // trying to find a "bad" class which breaks a dependency.
 746 // Such a class is called a "witness" to the broken dependency.
 747 // While searching around, we ignore "participants", which
 748 // are already known to the dependency.
 749 class ClassHierarchyWalker {
 750  public:
 751   enum { PARTICIPANT_LIMIT = 3 };
 752 
 753  private:
 754   // optional method descriptor to check for:
 755   Symbol* _name;
 756   Symbol* _signature;
 757 
 758   // special classes which are not allowed to be witnesses:


src/share/vm/code/dependencies.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File