@@ -55,10 +55,6 @@ enum IsDynamicallyReplaceable_t {
5555 IsNotDynamic,
5656 IsDynamic
5757};
58- // enum IsAdHocRequirementWitness_t {
59- // IsNotAdHocWitness,
60- // IsAdHocWitness
61- // };
6258enum IsExactSelfClass_t {
6359 IsNotExactSelfClass,
6460 IsExactSelfClass,
@@ -216,14 +212,16 @@ class SILFunction
216212 // / @_dynamicReplacement(for:) function.
217213 SILFunction *ReplacedFunction = nullptr ;
218214
219- // / Ad-hoc requirements may need to be retained explicitly, such that they
220- // / do not get optimized away as it might seem tha they are un-used.
215+ // / This SILFunction REFerences an ad-hoc protocol requirement witness in
216+ // / order to keep it alive, such that it main be obtained in IRGen. Without
217+ // / this explicit reference, the witness would seem not-used, and not be
218+ // / accessible for IRGen.
221219 // /
222- // / Specifically, e.g. the DistributedTargetInvocationDecoder's
223- // / 'decodeNextArgument' must be retained, as it is only used from IRGen
220+ // / Specifically, one such case is the DistributedTargetInvocationDecoder's
221+ // / 'decodeNextArgument' which must be retained, as it is only used from IRGen
224222 // / and such, appears as-if unused in SIL and would get optimized away.
225- // TODO: rename: referenced ad hoc requirement witnesses
226- SILFunction *AdHocRequirementFunction = nullptr ;
223+ // TODO: Consider making this a general "references adhoc functions" and make it an array?
224+ SILFunction *RefAdHocRequirementFunction = nullptr ;
227225
228226 Identifier ObjCReplacementFor;
229227
@@ -363,9 +361,6 @@ class SILFunction
363361 // / The function is in a statically linked module.
364362 unsigned IsStaticallyLinked : 1 ;
365363
366- // /// The function is a witness to an ad-hoc requirement.
367- // unsigned IsAdHocRequirementWitness : 1;
368-
369364 static void
370365 validateSubclassScope (SubclassScope scope, IsThunk_t isThunk,
371366 const GenericSpecializationInformation *genericInfo) {
@@ -490,28 +485,25 @@ class SILFunction
490485 ReplacedFunction = nullptr ;
491486 }
492487
493- SILFunction *getUsedAdHocRequirementWitnessFunction () const {
494- return AdHocRequirementFunction ;
488+ SILFunction *getReferencedAdHocRequirementWitnessFunction () const {
489+ return RefAdHocRequirementFunction ;
495490 }
496491 // Marks that this `SILFunction` uses the passed in ad-hoc protocol
497492 // requirement witness `f` and therefore must retain it explicitly,
498493 // otherwise we might not be able to get a reference to it.
499- void setUsedAdHocRequirementWitnessFunction (SILFunction *f) {
500- assert (AdHocRequirementFunction == nullptr && " already set" );
501-
502- fprintf (stderr, " [%s:%d] (%s) SET AD HOC WITNESS [%s] ON [%s]\n " , __FILE__, __LINE__, __FUNCTION__, f->getName ().str ().c_str (), this ->getName ().str ().c_str ());
503- f->dump ();
494+ void setReferencedAdHocRequirementWitnessFunction (SILFunction *f) {
495+ assert (RefAdHocRequirementFunction == nullptr && " already set" );
504496
505497 if (f == nullptr )
506498 return ;
507- AdHocRequirementFunction = f;
508- AdHocRequirementFunction ->incrementRefCount ();
499+ RefAdHocRequirementFunction = f;
500+ RefAdHocRequirementFunction ->incrementRefCount ();
509501 }
510- void dropAdHocRequirementFunction () {
511- if (!AdHocRequirementFunction )
502+ void dropReferencedAdHocRequirementWitnessFunction () {
503+ if (!RefAdHocRequirementFunction )
512504 return ;
513- AdHocRequirementFunction ->decrementRefCount ();
514- AdHocRequirementFunction = nullptr ;
505+ RefAdHocRequirementFunction ->decrementRefCount ();
506+ RefAdHocRequirementFunction = nullptr ;
515507 }
516508
517509 bool hasObjCReplacement () const {
@@ -789,15 +781,6 @@ class SILFunction
789781 assert (!Transparent || !IsDynamicReplaceable);
790782 }
791783
792- // / Returns whether this function implementation can be dynamically replaced.
793- // IsAdHocRequirementWitness_t isAdHocRequirementWitness() const {
794- // return IsAdHocRequirementWitness_t(IsAdHocRequirementWitness);
795- // }
796- // void setIsAdHocRequirementWitness(IsAdHocRequirementWitness_t value = IsAdHocWitness) {
797- // IsAdHocRequirementWitness = value;
798- // assert(!IsDynamicReplaceable);
799- // }
800-
801784 IsExactSelfClass_t isExactSelfClass () const {
802785 return IsExactSelfClass_t (ExactSelfClass);
803786 }
0 commit comments