|
1 |
| -// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -I %S/Inputs/custom-modules -enable-experimental-concurrency -disable-availability-checking %s -verify | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-cpu %s |
| 1 | +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -I %S/Inputs/custom-modules -enable-experimental-concurrency -disable-availability-checking %s -verify | %FileCheck --implicit-check-not=hop_to_executor --check-prefix=CHECK --check-prefix=CHECK-%target-cpu %s |
2 | 2 | // REQUIRES: concurrency
|
3 | 3 | // REQUIRES: objc_interop
|
4 | 4 |
|
@@ -114,9 +114,44 @@ class SlowServerlet: SlowServer {
|
114 | 114 |
|
115 | 115 | @FooActor
|
116 | 116 | class ActorConstrained: NSObject {
|
117 |
| - // CHECK-LABEL: sil shared [thunk] [ossa] @$s{{.*}}16ActorConstrainedC3foo{{.*}}U_To |
| 117 | + // ActorConstrained.foo() |
| 118 | + // CHECK-LABEL: sil hidden [ossa] @$s{{.*}}16ActorConstrainedC3foo{{.*}} : $@convention(method) @async (@guaranteed ActorConstrained) -> Bool { |
118 | 119 | // CHECK: hop_to_executor {{%.*}} : $FooActor
|
| 120 | + |
| 121 | + // @objc ActorConstrained.foo() |
| 122 | + // CHECK-LABEL: sil hidden [thunk] [ossa] @$s{{.*}}16ActorConstrainedC3foo{{.*}}To : $@convention(objc_method) (@convention(block) (Bool) -> (), ActorConstrained) -> () { |
| 123 | + // CHECK: [[ASYNC_CLOS:%[0-9]+]] = function_ref @$s{{.*}}16ActorConstrainedC3foo{{.*}}U_To : $@convention(thin) @Sendable @async (@convention(block) (Bool) -> (), ActorConstrained) -> () |
| 124 | + // CHECK: [[PRIMED_CLOS:%[0-9]+]] = partial_apply [callee_guaranteed] [[ASYNC_CLOS]]( |
| 125 | + // CHECK: [[TASK_RUNNER:%[0-9]+]] = function_ref @$ss29_runTaskForBridgedAsyncMethodyyyyYaYbcnF |
| 126 | + // CHECK: apply [[TASK_RUNNER]]([[PRIMED_CLOS]]) |
| 127 | + |
| 128 | + // @objc closure #1 in ActorConstrained.foo() |
| 129 | + // CHECK-LABEL: sil shared [thunk] [ossa] @$s{{.*}}16ActorConstrainedC3foo{{.*}}U_To : $@convention(thin) @Sendable @async (@convention(block) (Bool) -> (), ActorConstrained) -> () { |
| 130 | + // CHECK: hop_to_executor {{%.*}} : $FooActor |
119 | 131 | @objc func foo() async -> Bool {
|
120 | 132 | return true
|
121 | 133 | }
|
122 | 134 | }
|
| 135 | + |
| 136 | + |
| 137 | +actor Dril: NSObject { |
| 138 | + // Dril.postTo(twitter:) |
| 139 | + // CHECK-LABEL: sil hidden [ossa] @$s{{.*}}4DrilC6postTo7twitter{{.*}} : $@convention(method) @async (@guaranteed String, @guaranteed Dril) -> Bool { |
| 140 | + // CHECK: hop_to_executor {{%.*}} : $Dril |
| 141 | + |
| 142 | + // @objc Dril.postTo(twitter:) |
| 143 | + // CHECK-LABEL: sil hidden [thunk] [ossa] @$s{{.*}}4DrilC6postTo7twitter{{.*}}To : $@convention(objc_method) (NSString, @convention(block) (Bool) -> (), Dril) -> () { |
| 144 | + // CHECK: [[ASYNC_CLOS:%[0-9]+]] = function_ref @$s{{.*}}4DrilC6postTo7twitter{{.*}}U_To : $@convention(thin) @Sendable @async (NSString, @convention(block) (Bool) -> (), Dril) -> () |
| 145 | + // CHECK: [[PRIMED_CLOS:%[0-9]+]] = partial_apply [callee_guaranteed] [[ASYNC_CLOS]]( |
| 146 | + // CHECK: [[TASK_RUNNER:%[0-9]+]] = function_ref @$ss29_runTaskForBridgedAsyncMethodyyyyYaYbcnF |
| 147 | + // CHECK: apply [[TASK_RUNNER]]([[PRIMED_CLOS]]) |
| 148 | + @objc func postTo(twitter msg: String) async -> Bool { |
| 149 | + return true |
| 150 | + } |
| 151 | + |
| 152 | + // this is known to not emit a hop in the objc thunk (rdar://80972126) |
| 153 | + @MainActor |
| 154 | + @objc func postFromMainActorTo(twitter msg: String) -> Bool { |
| 155 | + return true |
| 156 | + } |
| 157 | +} |
0 commit comments