Skip to content

Commit 7c9ccb1

Browse files
committed
[Distributed] NFC: Adjust test-cases for account for new decoder handling
1 parent 72fca4c commit 7c9ccb1

File tree

4 files changed

+63
-45
lines changed

4 files changed

+63
-45
lines changed

test/Distributed/Inputs/FakeDistributedActorSystems.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,13 @@ public final class FakeRoundtripActorSystem: DistributedActorSystem, @unchecked
175175
self.remoteCallResult = nil
176176
self.remoteCallError = error
177177
}
178+
179+
var decoder = invocation.makeDecoder()
180+
178181
try await executeDistributedTarget(
179182
on: active,
180183
mangledTargetName: target.mangledName,
181-
invocationDecoder: invocation.makeDecoder(),
184+
invocationDecoder: &decoder,
182185
handler: resultHandler
183186
)
184187

@@ -222,10 +225,13 @@ public final class FakeRoundtripActorSystem: DistributedActorSystem, @unchecked
222225
self.remoteCallResult = nil
223226
self.remoteCallError = error
224227
}
228+
229+
var decoder = invocation.makeDecoder()
230+
225231
try await executeDistributedTarget(
226232
on: active,
227233
mangledTargetName: target.mangledName,
228-
invocationDecoder: invocation.makeDecoder(),
234+
invocationDecoder: &decoder,
229235
handler: resultHandler
230236
)
231237

test/Distributed/Runtime/distributed_actor_remoteCall.swift

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -299,44 +299,44 @@ func test() async throws {
299299
let local = Greeter(system: system)
300300

301301
// act as if we decoded an Invocation:
302-
let emptyInvocation = FakeInvocationDecoder(args: [])
302+
var emptyInvocation = FakeInvocationDecoder(args: [])
303303

304304
try await system.executeDistributedTarget(
305305
on: local,
306306
mangledTargetName: emptyName,
307-
invocationDecoder: emptyInvocation,
307+
invocationDecoder: &emptyInvocation,
308308
handler: FakeResultHandler()
309309
)
310310
// CHECK: RETURN: ()
311311

312312
try await system.executeDistributedTarget(
313313
on: local,
314314
mangledTargetName: helloName,
315-
invocationDecoder: emptyInvocation,
315+
invocationDecoder: &emptyInvocation,
316316
handler: FakeResultHandler()
317317
)
318318
// CHECK: RETURN: Hello, World!
319319

320320
try await system.executeDistributedTarget(
321321
on: local,
322322
mangledTargetName: answerName,
323-
invocationDecoder: emptyInvocation,
323+
invocationDecoder: &emptyInvocation,
324324
handler: FakeResultHandler()
325325
)
326326
// CHECK: RETURN: 42
327327

328328
try await system.executeDistributedTarget(
329329
on: local,
330330
mangledTargetName: largeResultName,
331-
invocationDecoder: emptyInvocation,
331+
invocationDecoder: &emptyInvocation,
332332
handler: FakeResultHandler()
333333
)
334334
// CHECK: RETURN: LargeStruct(q: "question", a: 42, b: 1, c: 2.0, d: "Lorum ipsum")
335335

336336
try await system.executeDistributedTarget(
337337
on: local,
338338
mangledTargetName: enumResultName,
339-
invocationDecoder: emptyInvocation,
339+
invocationDecoder: &emptyInvocation,
340340
handler: FakeResultHandler()
341341
)
342342
// CHECK: RETURN: bar
@@ -346,11 +346,11 @@ func test() async throws {
346346
try echoInvocation.recordArgument(42)
347347
try echoInvocation.doneRecording()
348348

349-
let echoDecoder = echoInvocation.makeDecoder()
349+
var echoDecoder = echoInvocation.makeDecoder()
350350
try await system.executeDistributedTarget(
351351
on: local,
352352
mangledTargetName: echoName,
353-
invocationDecoder: echoDecoder,
353+
invocationDecoder: &echoDecoder,
354354
handler: FakeResultHandler()
355355
)
356356
// CHECK: RETURN: Echo: name: Caplin, age: 42
@@ -361,11 +361,11 @@ func test() async throws {
361361
try generic1Invocation.recordArgument(42)
362362
try generic1Invocation.doneRecording()
363363

364-
let generic1Decoder = generic1Invocation.makeDecoder()
364+
var generic1Decoder = generic1Invocation.makeDecoder()
365365
try await system.executeDistributedTarget(
366366
on: local,
367367
mangledTargetName: generic1Name,
368-
invocationDecoder: generic1Decoder,
368+
invocationDecoder: &generic1Decoder,
369369
handler: FakeResultHandler()
370370
)
371371
// CHECK: ---> A = 42, type(of:) = Int
@@ -379,11 +379,11 @@ func test() async throws {
379379
try generic2Invocation.recordArgument("Ultimate Question!")
380380
try generic2Invocation.doneRecording()
381381

382-
let generic2Decoder = generic2Invocation.makeDecoder()
382+
var generic2Decoder = generic2Invocation.makeDecoder()
383383
try await system.executeDistributedTarget(
384384
on: local,
385385
mangledTargetName: generic2Name,
386-
invocationDecoder: generic2Decoder,
386+
invocationDecoder: &generic2Decoder,
387387
handler: FakeResultHandler()
388388
)
389389
// CHECK: ---> A = 42, type(of:) = Int
@@ -400,11 +400,11 @@ func test() async throws {
400400
try generic3Invocation.recordArgument(S(data: 42))
401401
try generic3Invocation.doneRecording()
402402

403-
let generic3Decoder = generic3Invocation.makeDecoder()
403+
var generic3Decoder = generic3Invocation.makeDecoder()
404404
try await system.executeDistributedTarget(
405405
on: local,
406406
mangledTargetName: generic3Name,
407-
invocationDecoder: generic3Decoder,
407+
invocationDecoder: &generic3Decoder,
408408
handler: FakeResultHandler()
409409
)
410410
// CHECK: ---> A = 42, type(of:) = Int
@@ -422,11 +422,11 @@ func test() async throws {
422422
try generic4Invocation.recordArgument(["a", "b", "c"])
423423
try generic4Invocation.doneRecording()
424424

425-
let generic4Decoder = generic4Invocation.makeDecoder()
425+
var generic4Decoder = generic4Invocation.makeDecoder()
426426
try await system.executeDistributedTarget(
427427
on: local,
428428
mangledTargetName: generic4Name,
429-
invocationDecoder: generic4Decoder,
429+
invocationDecoder: &generic4Decoder,
430430
handler: FakeResultHandler()
431431
)
432432
// CHECK: ---> A = 42, type(of:) = Int
@@ -446,11 +446,11 @@ func test() async throws {
446446
try generic5Invocation.recordArgument([0, 42])
447447
try generic5Invocation.doneRecording()
448448

449-
let generic5Decoder = generic5Invocation.makeDecoder()
449+
var generic5Decoder = generic5Invocation.makeDecoder()
450450
try await system.executeDistributedTarget(
451451
on: local,
452452
mangledTargetName: generic5Name,
453-
invocationDecoder: generic5Decoder,
453+
invocationDecoder: &generic5Decoder,
454454
handler: FakeResultHandler()
455455
)
456456
// CHECK: ---> A = 42, type(of:) = Int
@@ -469,11 +469,11 @@ func test() async throws {
469469
try genericOptInvocation.recordArgument([0, 42])
470470
try genericOptInvocation.doneRecording()
471471

472-
let genericOptDecoder = genericOptInvocation.makeDecoder()
472+
var genericOptDecoder = genericOptInvocation.makeDecoder()
473473
try await system.executeDistributedTarget(
474474
on: local,
475475
mangledTargetName: genericOptionalName,
476-
invocationDecoder: genericOptDecoder,
476+
invocationDecoder: &genericOptDecoder,
477477
handler: FakeResultHandler()
478478
)
479479
// CHECK: ---> T = [0, 42], type(of:) = Optional<Array<Int>>
@@ -484,11 +484,11 @@ func test() async throws {
484484
try decodeErrInvocation.recordArgument(42)
485485
try decodeErrInvocation.doneRecording()
486486

487-
let decodeErrDecoder = decodeErrInvocation.makeDecoder()
487+
var decodeErrDecoder = decodeErrInvocation.makeDecoder()
488488
try await system.executeDistributedTarget(
489489
on: local,
490490
mangledTargetName: expectsDecodeErrorName,
491-
invocationDecoder: decodeErrDecoder,
491+
invocationDecoder: &decodeErrDecoder,
492492
handler: FakeResultHandler()
493493
)
494494
// CHECK: ERROR: ExecuteDistributedTargetError(message: "Failed to decode of Int??? (for a test)")

test/Distributed/distributed_actor_accessor_thunks_32bit.swift

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,19 @@ public distributed actor MyOtherActor {
9494

9595
// CHECK: define hidden swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple1yySiFTE"
9696

97-
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple1yySiFTETF"(%swift.context* swiftasync %0, %T27FakeDistributedActorSystems0A17InvocationDecoderC* %1, i8* %2, i8* %3, {{.*}}, %T27distributed_actor_accessors7MyActorC* [[ACTOR:%.*]])
97+
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple1yySiFTETF"(%swift.context* swiftasync %0, %swift.opaque* nocapture %1, i8* %2, i8* %3, {{.*}}, %T27distributed_actor_accessors7MyActorC* [[ACTOR:%.*]], %swift.type* [[DECODER_TYPE:%.*]], i8** [[DECODER_PROTOCOL_WITNESS:%.*]])
9898

9999
/// Read the current offset and cast an element to `Int`
100100

101+
// CHECK: [[DECODER_PTR:%*]] = bitcast %swift.opaque* %1 to %T27FakeDistributedActorSystems0A17InvocationDecoderC**
102+
// CHECK-NEXT: [[DECODER:%.*]] = load %T27FakeDistributedActorSystems0A17InvocationDecoderC*, %T27FakeDistributedActorSystems0A17InvocationDecoderC** [[DECODER_PTR]]
103+
// CHECK-NEXT: [[DECODER_METADATA:%.*]] = bitcast %swift.type* [[DECODER_TYPE]] to void (%swift.opaque*, %swift.type*, i8**, i8**, %T27FakeDistributedActorSystems0A17InvocationDecoderC*, %swift.error**)**
104+
// CHECK-NEXT: [[DECODE_NEXT_ARG_REF:%.*]] = getelementptr inbounds void (%swift.opaque*, %swift.type*, i8**, i8**, %T27FakeDistributedActorSystems0A17InvocationDecoderC*, %swift.error**)*, void (%swift.opaque*, %swift.type*, i8**, i8**, %T27FakeDistributedActorSystems0A17InvocationDecoderC*, %swift.error**)** [[DECODER_METADATA]], i32 35
105+
// CHECK-NEXT: [[DECODE_NEXT_ARG:%.*]] = load void (%swift.opaque*, %swift.type*, i8**, i8**, %T27FakeDistributedActorSystems0A17InvocationDecoderC*, %swift.error**)*, void (%swift.opaque*, %swift.type*, i8**, i8**, %T27FakeDistributedActorSystems0A17InvocationDecoderC*, %swift.error**)** [[DECODE_NEXT_ARG_REF]]
106+
107+
101108
// CHECK: [[ARG_TYPES:%.*]] = bitcast i8* %2 to %swift.type**
102-
// CHECK-NEXT: [[DECODER:%.*]] = bitcast %T27FakeDistributedActorSystems0A17InvocationDecoderC* %1 to %swift.type**
103-
// CHECK-NEXT: [[DECODER_METADATA:%.*]] = load %swift.type*, %swift.type** [[DECODER]]
109+
104110
// CHECK: [[ARG_0_TYPE_LOC:%.*]] = getelementptr inbounds %swift.type*, %swift.type** [[ARG_TYPES]], i32 0
105111
// CHECK-NEXT: %arg_type = load %swift.type*, %swift.type** [[ARG_0_TYPE_LOC]]
106112
// CHECK: %size = load i32, i32* {{.*}}
@@ -120,7 +126,7 @@ public distributed actor MyOtherActor {
120126
// CHECK: missing-witness1:
121127
// CHECK-NEXT: call void @llvm.trap()
122128
// CHECK-NEXT: unreachable
123-
// CHECK: call swiftcc void {{.*}}(%swift.opaque* noalias nocapture sret(%swift.opaque) [[ARG_0_RES_SLOT]], %swift.type* %arg_type, i8** [[ENCODABLE_WITNESS]], i8** [[DECODABLE_WITNESS]], %T27FakeDistributedActorSystems0A17InvocationDecoderC* swiftself %1, %swift.error** noalias nocapture dereferenceable(4) %swifterror)
129+
// CHECK: call swiftcc void [[DECODE_NEXT_ARG]](%swift.opaque* noalias nocapture sret(%swift.opaque) [[ARG_0_RES_SLOT]], %swift.type* %arg_type, i8** [[ENCODABLE_WITNESS]], i8** [[DECODABLE_WITNESS]], %T27FakeDistributedActorSystems0A17InvocationDecoderC* swiftself [[DECODER]], %swift.error** noalias nocapture dereferenceable(4) %swifterror)
124130

125131
// CHECK: store %swift.error* null, %swift.error** %swifterror
126132
// CHECK-NEXT: [[ARG_0_VAL_ADDR:%.*]] = bitcast i8* [[ARG_0_VALUE_BUF]] to %TSi*
@@ -187,7 +193,8 @@ public distributed actor MyOtherActor {
187193
// CHECK: define hidden swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple3ySiSSFTE"
188194

189195
/// !!! in `simple3` interesting bits are: argument value extraction (because string is exploded into N arguments) and call to distributed thunk
190-
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple3ySiSSFTETF"(%swift.context* swiftasync {{.*}}, %T27FakeDistributedActorSystems0A17InvocationDecoderC* [[ARG_DECODER:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUFF:%.*]], i8* [[SUBS:%.*]], i8* [[WITNESS_TABLES:%.*]], i32 [[NUM_WITNESS_TABLES:%.*]], %T27distributed_actor_accessors7MyActorC* [[ACTOR:%.*]])
196+
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7simple3ySiSSFTETF"(%swift.context* swiftasync %0, %swift.opaque* nocapture [[ARG_DECODER:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUFF:%.*]], i8* [[SUBS:%.*]], i8* [[WITNESS_TABLES:%.*]], i32 [[NUM_WITNESS_TABLES:%.*]], %T27distributed_actor_accessors7MyActorC* [[ACTOR]], %swift.type* [[DECODER_TYPE:%.*]], i8** [[DECODER_PROTOCOL_WITNESS:%.*]])
197+
191198

192199
// CHECK: [[TYPED_RESULT_BUFF:%.*]] = bitcast i8* [[RESULT_BUFF]] to %TSi*
193200

@@ -245,7 +252,7 @@ public distributed actor MyOtherActor {
245252

246253
// CHECK: define hidden swifttailcc void @"$s27distributed_actor_accessors7MyActorC16single_case_enumyAA7SimpleEOAFFTE"
247254

248-
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC16single_case_enumyAA7SimpleEOAFFTETF"(%swift.context* swiftasync %0, %T27FakeDistributedActorSystems0A17InvocationDecoderC* [[ARG_DECODER:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUFF:%.*]], i8* [[SUBS:%.*]], i8* [[WITNESS_TABLES:%.*]], i32 [[NUM_WITNESS_TABLES:%.*]], %T27distributed_actor_accessors7MyActorC* [[ACTOR:%.*]])
255+
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC16single_case_enumyAA7SimpleEOAFFTETF"(%swift.context* swiftasync %0, %swift.opaque* nocapture [[ARG_DECODER:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUFF:%.*]], i8* [[SUBS:%.*]], i8* [[WITNESS_TABLES:%.*]], i32 [[NUM_WITNESS_TABLES:%.*]], %T27distributed_actor_accessors7MyActorC* [[ACTOR]], %swift.type* [[DECODER_TYPE]], i8** [[DECODER_PROTOCOL_WITNESS:%.*]])
249256

250257
/// Let's check that the call doesn't have any arguments and returns nothing.
251258

@@ -291,7 +298,7 @@ public distributed actor MyOtherActor {
291298

292299
// CHECK: define hidden swifttailcc void @"$s27distributed_actor_accessors7MyActorC7complexyAA11LargeStructVSaySiG_AA3ObjCSSSgAFtFTE"
293300

294-
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7complexyAA11LargeStructVSaySiG_AA3ObjCSSSgAFtFTETF"(%swift.context* swiftasync {{.*}}, %T27FakeDistributedActorSystems0A17InvocationDecoderC* [[ARG_DECODER:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUFF:%.*]], i8* [[SUBS:%.*]], i8* [[WITNESS_TABLES:%.*]], i32 [[NUM_WITNESS_TABLES:%.*]], %T27distributed_actor_accessors7MyActorC* [[ACTOR:%.*]])
301+
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC7complexyAA11LargeStructVSaySiG_AA3ObjCSSSgAFtFTETF"(%swift.context* swiftasync {{.*}}, %swift.opaque* nocapture [[ARG_DECODER:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUFF:%.*]], i8* [[SUBS:%.*]], i8* [[WITNESS_TABLES:%.*]], i32 [[NUM_WITNESS_TABLES:%.*]], %T27distributed_actor_accessors7MyActorC* [[ACTOR]], %swift.type* [[DECODER_TYPE:%.*]], i8** [[DECODER_PROTOCOL_WITNESS:%.*]])
295302

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

@@ -350,7 +357,7 @@ public distributed actor MyOtherActor {
350357

351358
/// ---> Accessor for `genericArgs`
352359

353-
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC11genericArgsyyx_Sayq_GtSeRzSERzSeR_SER_r0_lFTETF"(%swift.context* swiftasync %0, %T27FakeDistributedActorSystems0A17InvocationDecoderC* [[ARG_DECODER:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUF:%.*]], i8* [[GENERIC_SUBS:%.*]], i8* [[WITNESS_TABLES:%.*]], i32 [[NUM_WITNESS_TABLES:%.*]], %T27distributed_actor_accessors7MyActorC* [[ACTOR:%.*]])
360+
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors7MyActorC11genericArgsyyx_Sayq_GtSeRzSERzSeR_SER_r0_lFTETF"(%swift.context* swiftasync %0, %swift.opaque* nocapture [[ARG_DECODER:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUF:%.*]], i8* [[GENERIC_SUBS:%.*]], i8* [[WITNESS_TABLES:%.*]], i32 [[NUM_WITNESS_TABLES:%.*]], %T27distributed_actor_accessors7MyActorC* [[ACTOR:%.*]], %swift.type* [[DECODER_TYPE:%.*]], i8** [[DECODER_PROTOCOL_WITNESS:%.*]])
354361

355362
/// ---> Load `T`
356363

@@ -404,9 +411,9 @@ public distributed actor MyOtherActor {
404411

405412
/// ---> Thunk and distributed method for `MyOtherActor.empty`
406413

407-
/// Let's check that there is no offset allocation here since parameter list is empty
414+
/// Let's check that there is argument decoding since parameter list is empty
408415

409-
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors12MyOtherActorC5emptyyyFTETF"(%swift.context* swiftasync {{.*}}, %T27FakeDistributedActorSystems0A17InvocationDecoderC* [[ARG_DECODER:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUFF:%.*]], i8* [[SUBS:%.*]], i8* [[WITNESS_TABLES:%.*]], i32 [[NUM_WITNESS_TABLES:%.*]], %T27distributed_actor_accessors12MyOtherActorC* {{.*}})
416+
// CHECK: define internal swifttailcc void @"$s27distributed_actor_accessors12MyOtherActorC5emptyyyFTETF"(%swift.context* swiftasync {{.*}}, %swift.opaque* nocapture [[ARG_DECODER:%.*]], i8* [[ARG_TYPES:%.*]], i8* [[RESULT_BUFF:%.*]], i8* [[SUBS:%.*]], i8* [[WITNESS_TABLES:%.*]], i32 [[NUM_WITNESS_TABLES:%.*]], %T27distributed_actor_accessors12MyOtherActorC* {{.*}}, %swift.type* [[DECODER_TYPE:%.*]], i8** [[DECODER_PROTOCOL_WITNESS:%.*]])
410417
// CHECK-NEXT: entry:
411418
// CHECK-NEXT: {{.*}} = alloca %swift.context*
412419
// CHECK-NEXT: %swifterror = alloca %swift.error*

0 commit comments

Comments
 (0)