@@ -556,43 +556,12 @@ class Callee {
556
556
return result;
557
557
}
558
558
559
- SILDeclRef getCurriedConstant (bool isCurried) const {
560
- if (isCurried) {
561
- auto constant = Constant.asCurried ();
562
-
563
- // If we're currying a direct reference to a class-dispatched method,
564
- // make sure we emit the right set of thunks.
565
- if (kind == Kind::StandaloneFunction) {
566
- if (auto func = Constant.getAbstractFunctionDecl ()) {
567
- if (getMethodDispatch (func) == MethodDispatch::Class) {
568
- return constant.asDirectReference (true );
569
- }
570
- }
571
- }
572
-
573
- return constant;
574
- }
575
-
576
- return Constant;
577
- }
578
-
579
- ManagedValue getFnValue (SILGenFunction &SGF, bool isCurried,
559
+ ManagedValue getFnValue (SILGenFunction &SGF,
580
560
Optional<ManagedValue> borrowedSelf) const & {
581
561
Optional<SILDeclRef> constant = None;
582
562
583
- if (!Constant) {
584
- assert (!isCurried && " can't curry indirect function" );
585
- } else {
586
- constant = getCurriedConstant (isCurried);
587
-
588
- // If the call is curried, emit a direct call to the curry thunk.
589
- if (constant->isCurried ) {
590
- auto constantInfo =
591
- SGF.getConstantInfo (SGF.getTypeExpansionContext (), *constant);
592
- SILValue ref = SGF.emitGlobalFunctionRef (Loc, *constant, constantInfo);
593
- return ManagedValue::forUnmanaged (ref);
594
- }
595
- }
563
+ if (Constant)
564
+ constant = Constant;
596
565
597
566
switch (kind) {
598
567
case Kind::IndirectValue:
@@ -692,21 +661,11 @@ class Callee {
692
661
llvm_unreachable (" unhandled kind" );
693
662
}
694
663
695
- CalleeTypeInfo getTypeInfo (SILGenFunction &SGF, bool isCurried ) const & {
664
+ CalleeTypeInfo getTypeInfo (SILGenFunction &SGF) const & {
696
665
Optional<SILDeclRef> constant = None;
697
666
698
- if (!Constant) {
699
- assert (!isCurried && " can't curry indirect function" );
700
- } else {
701
- constant = getCurriedConstant (isCurried);
702
-
703
- // If the call is curried, emit a direct call to the curry thunk.
704
- if (constant->isCurried ) {
705
- auto constantInfo =
706
- SGF.getConstantInfo (SGF.getTypeExpansionContext (), *constant);
707
- return createCalleeTypeInfo (SGF, constant, constantInfo.getSILType ());
708
- }
709
- }
667
+ if (Constant)
668
+ constant = Constant;
710
669
711
670
switch (kind) {
712
671
case Kind::IndirectValue:
@@ -3579,14 +3538,7 @@ class CallEmission {
3579
3538
3580
3539
// / Is this a fully-applied enum element constructor call?
3581
3540
bool isEnumElementConstructor () {
3582
- return (callee.kind == Callee::Kind::EnumElement &&
3583
- uncurriedSites.size () == expectedSiteCount);
3584
- }
3585
-
3586
- // / True if this is a completely unapplied super method call
3587
- bool isPartiallyAppliedSuperMethod () {
3588
- return (callee.kind == Callee::Kind::SuperMethod &&
3589
- uncurriedSites.size () == 1 );
3541
+ return (callee.kind == Callee::Kind::EnumElement);
3590
3542
}
3591
3543
3592
3544
CleanupHandle applyCoroutine (SmallVectorImpl<ManagedValue> &yields);
@@ -3684,8 +3636,6 @@ class CallEmission {
3684
3636
FirstLevelApplicationResult
3685
3637
applySpecializedEmitter (SpecializedEmitter &specializedEmitter, SGFContext C);
3686
3638
3687
- FirstLevelApplicationResult applyPartiallyAppliedSuperMethod (SGFContext C);
3688
-
3689
3639
FirstLevelApplicationResult applyEnumElementConstructor (SGFContext C);
3690
3640
3691
3641
FirstLevelApplicationResult applyNormalCall (SGFContext C);
@@ -3743,10 +3693,8 @@ CallEmission::applyCoroutine(SmallVectorImpl<ManagedValue> &yields) {
3743
3693
auto origFormalType = callee.getOrigFormalType ();
3744
3694
CanFunctionType formalType = callee.getSubstFormalType ();
3745
3695
3746
- const bool isCurried = false ;
3747
-
3748
3696
// Get the callee type information.
3749
- auto calleeTypeInfo = callee.getTypeInfo (SGF, isCurried );
3697
+ auto calleeTypeInfo = callee.getTypeInfo (SGF);
3750
3698
3751
3699
SmallVector<ManagedValue, 4 > uncurriedArgs;
3752
3700
Optional<SILLocation> uncurriedLoc;
@@ -3764,7 +3712,7 @@ CallEmission::applyCoroutine(SmallVectorImpl<ManagedValue> &yields) {
3764
3712
borrowedSelf = uncurriedArgs.back ();
3765
3713
}
3766
3714
3767
- auto fnValue = callee.getFnValue (SGF, isCurried, borrowedSelf);
3715
+ auto fnValue = callee.getFnValue (SGF, borrowedSelf);
3768
3716
3769
3717
return SGF.emitBeginApply (uncurriedLoc.getValue (), fnValue,
3770
3718
callee.getSubstitutions (), uncurriedArgs,
@@ -3813,15 +3761,11 @@ SILGenFunction::emitBeginApply(SILLocation loc, ManagedValue fn,
3813
3761
3814
3762
CallEmission::FirstLevelApplicationResult
3815
3763
CallEmission::applyFirstLevelCallee (SGFContext C) {
3816
- // Check for a specialized emitter.
3817
- if (uncurriedSites.size () == expectedSiteCount) {
3818
- if (auto emitter = callee.getSpecializedEmitter (SGF.SGM )) {
3819
- return applySpecializedEmitter (emitter.getValue (), C);
3820
- }
3821
- }
3764
+ assert (uncurriedSites.size () == expectedSiteCount);
3822
3765
3823
- if (isPartiallyAppliedSuperMethod ()) {
3824
- return applyPartiallyAppliedSuperMethod (C);
3766
+ // Check for a specialized emitter.
3767
+ if (auto emitter = callee.getSpecializedEmitter (SGF.SGM )) {
3768
+ return applySpecializedEmitter (emitter.getValue (), C);
3825
3769
}
3826
3770
3827
3771
if (isEnumElementConstructor ()) {
@@ -3843,9 +3787,10 @@ CallEmission::applyNormalCall(SGFContext C) {
3843
3787
auto origFormalType = callee.getOrigFormalType ();
3844
3788
3845
3789
bool isCurried = (uncurriedSites.size () < callee.getParameterListCount ());
3790
+ assert (!isCurried);
3846
3791
3847
3792
// Get the callee type information.
3848
- auto calleeTypeInfo = callee.getTypeInfo (SGF, isCurried );
3793
+ auto calleeTypeInfo = callee.getTypeInfo (SGF);
3849
3794
3850
3795
// In C language modes, substitute the type of the AbstractionPattern
3851
3796
// so that we won't see type parameters down when we try to form bridging
@@ -3887,7 +3832,7 @@ CallEmission::applyNormalCall(SGFContext C) {
3887
3832
borrowedSelf = uncurriedArgs.back ();
3888
3833
}
3889
3834
3890
- auto mv = callee.getFnValue (SGF, isCurried, borrowedSelf);
3835
+ auto mv = callee.getFnValue (SGF, borrowedSelf);
3891
3836
3892
3837
// Emit the uncurried call.
3893
3838
firstLevelResult.value = SGF.emitApply (
@@ -3971,67 +3916,6 @@ CallEmission::applyEnumElementConstructor(SGFContext C) {
3971
3916
return firstLevelResult;
3972
3917
}
3973
3918
3974
- CallEmission::FirstLevelApplicationResult
3975
- CallEmission::applyPartiallyAppliedSuperMethod (SGFContext C) {
3976
- FirstLevelApplicationResult firstLevelResult;
3977
-
3978
- // We want to emit the arguments as fully-substituted values
3979
- // because that's what the partially applied super method expects;
3980
- firstLevelResult.formalType = callee.getSubstFormalType ();
3981
- auto origFormalType = AbstractionPattern (firstLevelResult.formalType );
3982
- auto substFnType = SGF.getSILFunctionType (
3983
- SGF.getTypeExpansionContext (), origFormalType, firstLevelResult.formalType );
3984
-
3985
- // Emit the arguments.
3986
- SmallVector<ManagedValue, 4 > uncurriedArgs;
3987
- Optional<SILLocation> uncurriedLoc;
3988
- CanFunctionType formalApplyType;
3989
- ApplyOptions options = emitArgumentsForNormalApply (
3990
- firstLevelResult.formalType , origFormalType, substFnType,
3991
- Optional<ForeignErrorConvention>(), firstLevelResult.foreignSelf ,
3992
- uncurriedArgs, uncurriedLoc, formalApplyType);
3993
- (void )options;
3994
-
3995
- // Emit the uncurried call.
3996
- assert (uncurriedArgs.size () == 1 && " Can only partially apply the "
3997
- " self parameter of a super "
3998
- " method call" );
3999
-
4000
- auto constant = callee.getMethodName ();
4001
- auto loc = uncurriedLoc.getValue ();
4002
- auto subs = callee.getSubstitutions ();
4003
- auto upcastedSelf = uncurriedArgs.back ();
4004
-
4005
- // Make sure that upcasted self is at +1 since we are going to place it into a
4006
- // partial_apply.
4007
- upcastedSelf = upcastedSelf.ensurePlusOne (SGF, loc);
4008
-
4009
- auto constantInfo =
4010
- SGF.getConstantInfo (SGF.getTypeExpansionContext (), callee.getMethodName ());
4011
- auto functionTy = constantInfo.getSILType ();
4012
- ManagedValue superMethod;
4013
- {
4014
- ArgumentScope S (SGF, loc);
4015
- ManagedValue castValue =
4016
- borrowedCastToOriginalSelfType (SGF, loc, upcastedSelf);
4017
- if (!constant.isForeign ) {
4018
- superMethod = SGF.B .createSuperMethod (loc, castValue, constant,
4019
- functionTy);
4020
- } else {
4021
- superMethod = SGF.B .createObjCSuperMethod (loc, castValue, constant,
4022
- functionTy);
4023
- }
4024
- S.pop ();
4025
- }
4026
- auto calleeConvention = ParameterConvention::Direct_Guaranteed;
4027
-
4028
- ManagedValue pa = SGF.B .createPartialApply (loc, superMethod,
4029
- subs, {upcastedSelf},
4030
- calleeConvention);
4031
- firstLevelResult.value = RValue (SGF, loc, formalApplyType.getResult (), pa);
4032
- return firstLevelResult;
4033
- }
4034
-
4035
3919
CallEmission::FirstLevelApplicationResult
4036
3920
CallEmission::applySpecializedEmitter (SpecializedEmitter &specializedEmitter,
4037
3921
SGFContext C) {
@@ -4086,7 +3970,7 @@ CallEmission::applySpecializedEmitter(SpecializedEmitter &specializedEmitter,
4086
3970
// result plan/arg scope before we prepare arguments.
4087
3971
if (!specializedEmitter.isLateEmitter () &&
4088
3972
substConv.hasIndirectSILResults ()) {
4089
- calleeTypeInfo.emplace (callee.getTypeInfo (SGF, false /* isCurried */ ));
3973
+ calleeTypeInfo.emplace (callee.getTypeInfo (SGF));
4090
3974
4091
3975
calleeTypeInfo->origResultType = origFormalType.getFunctionResultType ();
4092
3976
calleeTypeInfo->substResultType = callee.getSubstFormalType ().getResult ();
@@ -4849,13 +4733,12 @@ SILGenFunction::emitApplyOfLibraryIntrinsic(SILLocation loc,
4849
4733
auto origFormalType = callee.getOrigFormalType ();
4850
4734
auto substFormalType = callee.getSubstFormalType ();
4851
4735
4852
- auto calleeTypeInfo = callee.getTypeInfo (*this , /* isCurried= */ false );
4736
+ auto calleeTypeInfo = callee.getTypeInfo (*this );
4853
4737
4854
4738
Optional<ManagedValue> borrowedSelf;
4855
4739
if (callee.requiresSelfValueForDispatch ())
4856
4740
borrowedSelf = args.back ();
4857
- auto mv = callee.getFnValue (*this , /* isCurried=*/ false ,
4858
- borrowedSelf);
4741
+ auto mv = callee.getFnValue (*this , borrowedSelf);
4859
4742
4860
4743
assert (!calleeTypeInfo.foreignError );
4861
4744
assert (!calleeTypeInfo.foreignSelf .isImportAsMember ());
0 commit comments