@@ -55,10 +55,6 @@ enum IsDynamicallyReplaceable_t {
55
55
IsNotDynamic,
56
56
IsDynamic
57
57
};
58
- // enum IsAdHocRequirementWitness_t {
59
- // IsNotAdHocWitness,
60
- // IsAdHocWitness
61
- // };
62
58
enum IsExactSelfClass_t {
63
59
IsNotExactSelfClass,
64
60
IsExactSelfClass,
@@ -216,14 +212,16 @@ class SILFunction
216
212
// / @_dynamicReplacement(for:) function.
217
213
SILFunction *ReplacedFunction = nullptr ;
218
214
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.
221
219
// /
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
224
222
// / 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 ;
227
225
228
226
Identifier ObjCReplacementFor;
229
227
@@ -363,9 +361,6 @@ class SILFunction
363
361
// / The function is in a statically linked module.
364
362
unsigned IsStaticallyLinked : 1 ;
365
363
366
- // /// The function is a witness to an ad-hoc requirement.
367
- // unsigned IsAdHocRequirementWitness : 1;
368
-
369
364
static void
370
365
validateSubclassScope (SubclassScope scope, IsThunk_t isThunk,
371
366
const GenericSpecializationInformation *genericInfo) {
@@ -490,28 +485,25 @@ class SILFunction
490
485
ReplacedFunction = nullptr ;
491
486
}
492
487
493
- SILFunction *getUsedAdHocRequirementWitnessFunction () const {
494
- return AdHocRequirementFunction ;
488
+ SILFunction *getReferencedAdHocRequirementWitnessFunction () const {
489
+ return RefAdHocRequirementFunction ;
495
490
}
496
491
// Marks that this `SILFunction` uses the passed in ad-hoc protocol
497
492
// requirement witness `f` and therefore must retain it explicitly,
498
493
// 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" );
504
496
505
497
if (f == nullptr )
506
498
return ;
507
- AdHocRequirementFunction = f;
508
- AdHocRequirementFunction ->incrementRefCount ();
499
+ RefAdHocRequirementFunction = f;
500
+ RefAdHocRequirementFunction ->incrementRefCount ();
509
501
}
510
- void dropAdHocRequirementFunction () {
511
- if (!AdHocRequirementFunction )
502
+ void dropReferencedAdHocRequirementWitnessFunction () {
503
+ if (!RefAdHocRequirementFunction )
512
504
return ;
513
- AdHocRequirementFunction ->decrementRefCount ();
514
- AdHocRequirementFunction = nullptr ;
505
+ RefAdHocRequirementFunction ->decrementRefCount ();
506
+ RefAdHocRequirementFunction = nullptr ;
515
507
}
516
508
517
509
bool hasObjCReplacement () const {
@@ -789,15 +781,6 @@ class SILFunction
789
781
assert (!Transparent || !IsDynamicReplaceable);
790
782
}
791
783
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
-
801
784
IsExactSelfClass_t isExactSelfClass () const {
802
785
return IsExactSelfClass_t (ExactSelfClass);
803
786
}
0 commit comments