Skip to content

Commit 925b598

Browse files
committed
[Distributed] IRGen: Drop result type for accessor parameters
1 parent 51df874 commit 925b598

File tree

4 files changed

+15
-21
lines changed

4 files changed

+15
-21
lines changed

lib/IRGen/GenDistributed.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static CanSILFunctionType getAccessorType(IRGenModule &IGM,
152152
assert(targetTy->isAsync());
153153
assert(targetTy->hasErrorResult());
154154

155-
// Accessor gets argument value buffer and a reference to `self` of
155+
// Accessor gets argument/result value buffer and a reference to `self` of
156156
// the actor and produces a call to the distributed thunk forwarding
157157
// its result(s) out.
158158
return SILFunctionType::get(
@@ -161,7 +161,6 @@ static CanSILFunctionType getAccessorType(IRGenModule &IGM,
161161
{/*argumentBuffer=*/getRawPointerParameter(),
162162
/*argumentTypes=*/getRawPointerParameter(),
163163
/*resultBuffer=*/getRawPointerParameter(),
164-
/*resultType=*/getRawPointerParameter(),
165164
/*actor=*/targetTy->getParameters().back()},
166165
/*Yields=*/{},
167166
/*Results=*/{},
@@ -438,8 +437,6 @@ void DistributedAccessor::emit() {
438437
auto *argTypes = params.claimNext();
439438
// UnsafeRawPointer that is used to store the result.
440439
auto *resultBuffer = params.claimNext();
441-
// `swift.type*` that holds the type fo the result.
442-
auto *resultType = params.claimNext();
443440
// Reference to a `self` of the actor to be called.
444441
auto *actorSelf = params.claimNext();
445442

stdlib/public/Concurrency/Actor.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,14 +1722,15 @@ void *swift_distributed_get_generic_environment(const char *targetNameStart,
17221722
/// _ targetName: UnsafePointer<UInt8>,
17231723
/// _ targetNameLength: UInt,
17241724
/// argumentBuffer: Builtin.RawPointer,
1725-
/// resultBuffer: Builtin.RawPointer) async throws
1725+
/// argumentTypes: UnsafeBufferPointer<Any.Type>,
1726+
/// resultBuffer: Builtin.RawPointer
1727+
/// ) async throws
17261728
using TargetExecutorSignature =
17271729
AsyncSignature<void(/*on=*/DefaultActor *,
17281730
/*targetName=*/const char *, /*targetNameSize=*/size_t,
17291731
/*argumentBuffer=*/void *,
17301732
/*argumentTypes=*/const Metadata *const *,
17311733
/*resultBuffer=*/void *,
1732-
/*resultType=*/const Metadata *,
17331734
/*resumeFunc=*/TaskContinuationFunction *,
17341735
/*callContext=*/AsyncContext *),
17351736
/*throws=*/true>;
@@ -1747,7 +1748,6 @@ using DistributedAccessorSignature =
17471748
AsyncSignature<void(/*argumentBuffer=*/void *,
17481749
/*argumentTypes=*/const Metadata *const *,
17491750
/*resultBuffer=*/void *,
1750-
/*resultType=*/const Metadata *,
17511751
/*actor=*/HeapObject *),
17521752
/*throws=*/true>;
17531753

@@ -1777,7 +1777,6 @@ void ::swift_distributed_execute_target(
17771777
void *argumentBuffer,
17781778
const Metadata *const *argumentTypes,
17791779
void *resultBuffer,
1780-
const Metadata *resultType,
17811780
TaskContinuationFunction *resumeFunc,
17821781
AsyncContext *callContext) {
17831782
auto *accessor = findDistributedAccessor(targetNameStart, targetNameLength);
@@ -1813,6 +1812,6 @@ void ::swift_distributed_execute_target(
18131812

18141813
accessorEntry(calleeContext,
18151814
argumentBuffer, argumentTypes,
1816-
resultBuffer, resultType,
1815+
resultBuffer,
18171816
actor);
18181817
}

stdlib/public/Distributed/DistributedActorSystem.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,7 @@ extension DistributedActorSystem {
307307
mangledTargetName, UInt(mangledTargetName.count),
308308
argumentBuffer: hargs.buffer._rawValue, // TODO(distributed): pass the invocationDecoder instead, so we can decode inside IRGen directly into the argument explosion
309309
argumentTypes: argumentTypesBuffer.baseAddress!._rawValue,
310-
resultBuffer: resultBuffer._rawValue,
311-
resultType: returnTypeFromTypeInfo
310+
resultBuffer: resultBuffer._rawValue
312311
)
313312

314313
func onReturn<R>(_ resultTy: R.Type) async throws {
@@ -328,8 +327,7 @@ func _executeDistributedTarget(
328327
_ targetName: UnsafePointer<UInt8>, _ targetNameLength: UInt,
329328
argumentBuffer: Builtin.RawPointer, // HeterogeneousBuffer of arguments
330329
argumentTypes: Builtin.RawPointer,
331-
resultBuffer: Builtin.RawPointer,
332-
resultType: Any.Type
330+
resultBuffer: Builtin.RawPointer
333331
) async throws
334332

335333
// ==== ----------------------------------------------------------------------------------------------------------------

test/Distributed/distributed_actor_accessor_thunks_64bit.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public distributed actor MyOtherActor {
9090

9191
// CHECK: define hidden swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple1yySiFTE"
9292

93-
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple1yySiFTETF"(%swift.context* swiftasync %0, i8* %1, i8* %2, i8* %3, i8* %4, %T27distributed_actor_accessors7MyActorC* %5)
93+
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple1yySiFTETF"(%swift.context* swiftasync %0, i8* %1, i8* %2, i8* %3, %T27distributed_actor_accessors7MyActorC* %4)
9494

9595
/// Read the current offset and cast an element to `Int`
9696

@@ -113,7 +113,7 @@ public distributed actor MyOtherActor {
113113
// CHECK-SAME: i8* bitcast (void (%swift.context*, i64, %T27distributed_actor_accessors7MyActorC*)* @"$s27distributed_actor_accessors7MyActorC7simple1yySiFTE" to i8*),
114114
// CHECK-SAME: %swift.context* [[THUNK_CONTEXT_PTR]],
115115
// CHECK-SAME: i64 [[ARG_VAL]],
116-
// CHECK-SAME: %T27distributed_actor_accessors7MyActorC* %5)
116+
// CHECK-SAME: %T27distributed_actor_accessors7MyActorC* %4)
117117

118118
// CHECK-NEXT: [[TASK_REF:%.*]] = extractvalue { i8*, %swift.error* } [[THUNK_RESULT]], 0
119119
// CHECK-NEXT: {{.*}} = call i8* @__swift_async_resume_project_context(i8* [[TASK_REF]])
@@ -141,7 +141,7 @@ public distributed actor MyOtherActor {
141141
// CHECK-SAME: i8* bitcast (void (%swift.context*, i64, %T27distributed_actor_accessors7MyActorC*)* @"$s27distributed_actor_accessors7MyActorC7simple2ySSSiFTE" to i8*),
142142
// CHECK-SAME: %swift.context* [[THUNK_CONTEXT_PTR]],
143143
// CHECK-SAME: i64 [[NATIVE_ARG_VAL]],
144-
// CHECK-SAME: %T27distributed_actor_accessors7MyActorC* %5)
144+
// CHECK-SAME: %T27distributed_actor_accessors7MyActorC* %4)
145145

146146
// CHECK-NEXT: [[TASK_REF:%.*]] = extractvalue { i8*, i64, %swift.bridge*, %swift.error* } [[THUNK_RESULT]], 0
147147
// CHECK-NEXT: {{.*}} = call i8* @__swift_async_resume_project_context(i8* [[TASK_REF]])
@@ -164,7 +164,7 @@ public distributed actor MyOtherActor {
164164
// CHECK: define hidden swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple3ySiSSFTE"
165165

166166
/// !!! in `simple3` interesting bits are: argument value extraction (because string is exploded into N arguments) and call to distributed thunk
167-
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple3ySiSSFTETF"(%swift.context* swiftasync {{.*}}, i8* [[ARG_BUFF:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUFF:%.*]], {{.*}}, %T27distributed_actor_accessors7MyActorC* {{.*}})
167+
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple3ySiSSFTETF"(%swift.context* swiftasync {{.*}}, i8* [[ARG_BUFF:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUFF:%.*]], %T27distributed_actor_accessors7MyActorC* {{.*}})
168168

169169
// CHECK: [[TYPED_RESULT_BUFF:%.*]] = bitcast i8* [[RESULT_BUFF]] to %TSi*
170170

@@ -188,7 +188,7 @@ public distributed actor MyOtherActor {
188188
// CHECK-SAME: %swift.context* [[THUNK_CONTEXT_PTR]],
189189
// CHECK-SAME: i64 [[STR_SIZE]],
190190
// CHECK-SAME: %swift.bridge* [[STR_VAL]],
191-
// CHECK-SAME: %T27distributed_actor_accessors7MyActorC* %5)
191+
// CHECK-SAME: %T27distributed_actor_accessors7MyActorC* %4)
192192

193193
// CHECK-NEXT: [[TASK_REF:%.*]] = extractvalue { i8*, i64, %swift.error* } [[THUNK_RESULT]], 0
194194
// CHECK-NEXT: {{.*}} = call i8* @__swift_async_resume_project_context(i8* [[TASK_REF]])
@@ -201,7 +201,7 @@ public distributed actor MyOtherActor {
201201

202202
// CHECK: define hidden swifttailcc void @"$s27distributed_actor_accessors7MyActorC16single_case_enumyAA7SimpleEOAFFTE"
203203

204-
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC16single_case_enumyAA7SimpleEOAFFTETF"(%swift.context* swiftasync %0, i8* [[BUFFER:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUFF:%.*]], {{.*}}, %T27distributed_actor_accessors7MyActorC* {{.*}})
204+
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC16single_case_enumyAA7SimpleEOAFFTETF"(%swift.context* swiftasync %0, i8* [[BUFFER:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUFF:%.*]], %T27distributed_actor_accessors7MyActorC* {{.*}})
205205

206206
/// First, let's check that there were no loads from the argument buffer and no stores to "current offset".
207207

@@ -256,7 +256,7 @@ public distributed actor MyOtherActor {
256256

257257
// CHECK: define hidden swifttailcc void @"$s27distributed_actor_accessors7MyActorC7complexyAA11LargeStructVSaySiG_AA3ObjCSSSgAFtFTE"
258258

259-
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7complexyAA11LargeStructVSaySiG_AA3ObjCSSSgAFtFTETF"(%swift.context* swiftasync {{.*}}, i8* [[ARG_BUFF:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUFF:%.*]], {{.*}}, %T27distributed_actor_accessors7MyActorC* {{.*}})
259+
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7complexyAA11LargeStructVSaySiG_AA3ObjCSSSgAFtFTETF"(%swift.context* swiftasync {{.*}}, i8* [[ARG_BUFF:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUFF:%.*]], %T27distributed_actor_accessors7MyActorC* {{.*}})
260260

261261
/// First, let's check that all of the different argument types here are loaded correctly.
262262

@@ -317,7 +317,7 @@ public distributed actor MyOtherActor {
317317

318318
/// Let's check that there is no offset allocation here since parameter list is empty
319319

320-
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors12MyOtherActorC5emptyyyFTETF"(%swift.context* swiftasync {{.*}}, i8* [[ARG_BUFF:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUFF:%.*]], {{.*}}, %T27distributed_actor_accessors12MyOtherActorC* {{.*}})
320+
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors12MyOtherActorC5emptyyyFTETF"(%swift.context* swiftasync {{.*}}, i8* [[ARG_BUFF:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUFF:%.*]], %T27distributed_actor_accessors12MyOtherActorC* {{.*}})
321321
// CHECK-NEXT: entry:
322322
// CHECK-NEXT: {{.*}} = alloca %swift.context*
323323
// CHECK-NEXT: %swifterror = alloca swifterror %swift.error*

0 commit comments

Comments
 (0)