Mercurial > hg > truffle
comparison src/share/vm/code/dependencies.cpp @ 14505:524b54a7f1b5
8034839: jvm hangs with gc/gctests/LoadUnloadGC test
Summary: Provide fast lookup of checked dependencies via hashmap
Reviewed-by: kvn, roland
author | anoll |
---|---|
date | Wed, 26 Feb 2014 11:29:47 +0100 |
parents | cb0dc98c287d |
children | d8041d695d19 3c6ae9109a86 |
comparison
equal
deleted
inserted
replaced
14461:a13badbb8b8e | 14505:524b54a7f1b5 |
---|---|
723 // e.g. evol_method. | 723 // e.g. evol_method. |
724 return NULL; | 724 return NULL; |
725 } | 725 } |
726 | 726 |
727 // ----------------- DependencySignature -------------------------------------- | 727 // ----------------- DependencySignature -------------------------------------- |
728 bool DependencySignature::equals(const DependencySignature& sig) const { | 728 bool DependencySignature::equals(DependencySignature* sig) const { |
729 if (type() != sig.type()) { | 729 if ((type() != sig->type()) || (args_count() != sig->args_count())) { |
730 return false; | 730 return false; |
731 } | 731 } |
732 | 732 |
733 if (args_count() != sig.args_count()) { | 733 for (int i = 0; i < sig->args_count(); i++) { |
734 return false; | 734 if (arg(i) != sig->arg(i)) { |
735 } | |
736 | |
737 for (int i = 0; i < sig.args_count(); i++) { | |
738 if (arg(i) != sig.arg(i)) { | |
739 return false; | 735 return false; |
740 } | 736 } |
741 } | 737 } |
742 return true; | 738 return true; |
743 } | 739 } |
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 | 740 |
778 /// Checking dependencies: | 741 /// Checking dependencies: |
779 | 742 |
780 // This hierarchy walker inspects subtypes of a given type, | 743 // This hierarchy walker inspects subtypes of a given type, |
781 // trying to find a "bad" class which breaks a dependency. | 744 // trying to find a "bad" class which breaks a dependency. |