Skip to content

Commit 60a07b2

Browse files
authored
Merge pull request swiftlang#36573 from jckarter/reinstate-continuation-executor
IRGen: Initialize the executor field in continuation contexts again.
2 parents 5afe404 + 0f395e3 commit 60a07b2

File tree

5 files changed

+52
-6
lines changed

5 files changed

+52
-6
lines changed

lib/IRGen/IRGenFunction.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,11 @@ void IRGenFunction::emitGetAsyncContinuation(SILType resumeTy,
593593
contResultAddr->getType()->getPointerElementType()),
594594
Address(contResultAddr, pointerAlignment));
595595
}
596-
// FIXME:
597-
// continuation_context.resumeExecutor = // current executor
596+
auto executorAddr =
597+
Builder.CreateStructGEP(continuationContext.getAddress(), 4);
598+
auto executor = Builder.CreateCall(IGM.getTaskGetCurrentExecutorFn(), {});
599+
executorAddr = Builder.CreateBitCast(executorAddr, executor->getType()->getPointerTo());
600+
Builder.CreateStore(executor, executorAddr, pointerAlignment);
598601

599602
// Fill the current task (i.e the continuation) with the continuation
600603
// information.

test/Concurrency/Runtime/objc_async.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
// REQUIRES: concurrency
88
// REQUIRES: objc_interop
99

10-
// This test is flaky and crashes sometimes, mostly when testing with swift_test_mode_optimize.
11-
// REQUIRES: rdar75783864
12-
13-
1410
@main struct Main {
1511
static func main() async {
1612
let butt = Butt()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <Foundation/Foundation.h>
2+
3+
@interface Butt: NSObject
4+
5+
- (instancetype _Nonnull)init;
6+
7+
- (void)butt:(NSInteger)x completionHandler:(void (^ _Nonnull)(NSInteger))handler;
8+
9+
@end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "objc_async.h"
2+
#include <stdio.h>
3+
4+
@implementation Butt
5+
6+
- (instancetype)init {
7+
return [super init];
8+
}
9+
10+
- (void)butt:(NSInteger)x completionHandler:(void (^)(NSInteger))handler {
11+
printf("starting %ld\n", (long)x);
12+
handler(679);
13+
}
14+
15+
@end

test/Sanitizers/tsan/objc_async.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-clang -fsanitize=thread %S/Inputs/objc_async.m -c -o %t/objc_async_objc.o
3+
// RUN: %target-build-swift -sanitize=thread -O -Xfrontend -enable-experimental-concurrency -parse-as-library -module-name main -import-objc-header %S/Inputs/objc_async.h %s %t/objc_async_objc.o -o %t/objc_async
4+
// RUN: %target-run %t/objc_async | %FileCheck %s
5+
6+
// REQUIRES: executable_test
7+
// REQUIRES: concurrency
8+
// REQUIRES: objc_interop
9+
// REQUIRES: tsan_runtime
10+
// UNSUPPORTED: linux
11+
// UNSUPPORTED: windows
12+
13+
14+
@main struct Main {
15+
static func main() async {
16+
let butt = Butt()
17+
let result = await butt.butt(1738)
18+
print("finishing \(result)")
19+
}
20+
}
21+
22+
// CHECK: starting 1738
23+
// CHECK-NEXT: finishing 679

0 commit comments

Comments
 (0)