Skip to content

Commit 4d45701

Browse files
committed
[Sema/IRGen] Extend ad-hoc requirement handling to DistributedTargetInvocationDecoder.decodeNextArgument
1 parent 4f32111 commit 4d45701

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

lib/IRGen/GenProto.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ class EmitPolymorphicParameters : public PolymorphicConvention {
551551
// If we are building a protocol witness thunks for
552552
// `DistributedActorSystem.remoteCall` or
553553
// `DistributedTargetInvocationEncoder.record{Argument, ReturnType}`
554+
// `DistributedTargetInvocationDecoder.decodeNextArgument`
554555
// requirements we need to supply witness tables associated with `Res`,
555556
// `Argument`, `R` generic parameters which are not expressible on the
556557
// protocol requirement because they come from `SerializationRequirement`
@@ -739,21 +740,23 @@ void EmitPolymorphicParameters::injectAdHocDistributedRequirements() {
739740

740741
auto loc = Fn.getLocation();
741742

742-
Type genericParam;
743-
744743
auto *funcDecl = dyn_cast_or_null<FuncDecl>(loc.getAsDeclContext());
745744
if (!(funcDecl && funcDecl->isGeneric()))
746745
return;
747746

747+
Type genericParam;
748+
748749
// DistributedActorSystem.remoteCall
749750
if (funcDecl->isDistributedActorSystemRemoteCall(
750751
/*isVoidReturn=*/false)) {
751752
genericParam = funcDecl->getResultInterfaceType();
752753
}
753754

754755
// DistributedTargetInvocationEncoder.record{Argument, ReturnType}
756+
// DistributedTargetInvocationDecoder.decodeNextArgument
755757
if (funcDecl->isDistributedTargetInvocationEncoderRecordArgument() ||
756-
funcDecl->isDistributedTargetInvocationEncoderRecordReturnType()) {
758+
funcDecl->isDistributedTargetInvocationEncoderRecordReturnType() ||
759+
funcDecl->isDistributedTargetInvocationDecoderDecodeNextArgument()) {
757760
auto *argParam = funcDecl->getGenericParams()->getParams().front();
758761
genericParam = argParam->getDeclaredInterfaceType();
759762
}

lib/Sema/CSSimplify.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8599,8 +8599,10 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
85998599
}
86008600

86018601
// `DistributedTargetInvocationEncoder.record{Argument, ResultType}`
8602+
// `DistributedTargetInvocationDecoder.decodeNextArgument`
86028603
if (witness->isDistributedTargetInvocationEncoderRecordArgument() ||
8603-
witness->isDistributedTargetInvocationEncoderRecordReturnType()) {
8604+
witness->isDistributedTargetInvocationEncoderRecordReturnType() ||
8605+
witness->isDistributedTargetInvocationDecoderDecodeNextArgument()) {
86048606
auto genericParams = witness->getGenericParams()->getParams();
86058607
if (GP->isEqual(genericParams.front()->getDeclaredInterfaceType()))
86068608
return synthesizeConformance();

stdlib/public/Distributed/DistributedActorSystem.swift

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -890,20 +890,18 @@ public protocol DistributedTargetInvocationDecoder {
890890
/// - Throws: if decoding substitutions fails.
891891
mutating func decodeGenericSubstitutions() throws -> [Any.Type]
892892

893-
// /// Ad-hoc protocol requirement
894-
// ///
895-
// /// Attempt to decode the next argument from the underlying buffers into pre-allocated storage
896-
// /// pointed at by 'pointer'.
897-
// ///
898-
// /// This method should throw if it has no more arguments available, if decoding the argument failed,
899-
// /// or, optionally, if the argument type we're trying to decode does not match the stored type.
900-
// ///
901-
// /// The result of the decoding operation must be stored into the provided 'pointer' rather than
902-
// /// returning a value. This pattern allows the runtime to use a heavily optimized, pre-allocated
903-
// /// buffer for all the arguments and their expected types. The 'pointer' passed here is a pointer
904-
// /// to a "slot" in that pre-allocated buffer. That buffer will then be passed to a thunk that
905-
// /// performs the actual distributed (local) instance method invocation.
906-
// mutating func decodeNextArgument<Argument: SerializationRequirement>() throws -> Argument
893+
/// Attempt to decode the next argument from the underlying buffers into pre-allocated storage
894+
/// pointed at by 'pointer'.
895+
///
896+
/// This method should throw if it has no more arguments available, if decoding the argument failed,
897+
/// or, optionally, if the argument type we're trying to decode does not match the stored type.
898+
///
899+
/// The result of the decoding operation must be stored into the provided 'pointer' rather than
900+
/// returning a value. This pattern allows the runtime to use a heavily optimized, pre-allocated
901+
/// buffer for all the arguments and their expected types. The 'pointer' passed here is a pointer
902+
/// to a "slot" in that pre-allocated buffer. That buffer will then be passed to a thunk that
903+
/// performs the actual distributed (local) instance method invocation.
904+
mutating func decodeNextArgument<Argument/*: SerializationRequirement*/>() throws -> Argument
907905

908906
/// Decode the specific error type that the distributed invocation target has recorded.
909907
/// Currently this effectively can only ever be `Error.self`.

0 commit comments

Comments
 (0)