Skip to content

[DiscardingTG] Remove reabstraction thunk for () -> Void to () -> T #70537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kateinoigakukun
Copy link
Member

Concurrency runtime expects discarding task operation entrypoint function not to have result type, but the current SILGen implementation generates reabstraction thunk to convert () -> Void to () -> T for the operation function.

Since the T is always Void for DiscardingTG, the mismatch of result type expectation does not cause any problem on most platforms, but the signature mismatch causes a problem on WebAssembly.

This patch introduces new builtin operations for creating discarding task, which always takes () -> Void as the operation function type.

The issue #63060 was partially fixed by #66219, but #68793 revealed the issue again since it added extra reabstraction for the given operation closure.

Concurrency runtime expects discarding task operation entrypoint
function not to have result type, but the current SILGen
implementation generates reabstraction thunk to convert `() -> Void`
to `() -> T` for the operation function.

Since the `T` is always `Void` for DiscardingTG, the mismatch of result
type expectation does not cause any problem on most platforms, but the
signature mismatch causes a problem on WebAssembly.

This patch introduces new builtin operations for creating discarding
task, which always takes `() -> Void` as the operation function type.
@kateinoigakukun
Copy link
Member Author

@swift-ci Please test

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jckarter Maybe there's a way to achieve this without a new builtin, using your reabstraction peephole logic?

@MaxDesiatov
Copy link
Contributor

@swift-ci test

@xedin xedin removed their request for review January 8, 2024 02:17
@MaxDesiatov
Copy link
Contributor

@swift-ci test

@ktoso ktoso added concurrency runtime Feature: umbrella label for concurrency runtime features concurrency Feature: umbrella label for concurrency language features labels Jan 9, 2024
Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing this up, I missed the discarding group with the latest work — thanks! LGTM

@ktoso ktoso merged commit 7cccbcc into swiftlang:main Jan 9, 2024
Catfish-Man pushed a commit to Catfish-Man/swift that referenced this pull request Jan 19, 2024
…T` (swiftlang#70537)

Concurrency runtime expects discarding task operation entrypoint
function not to have result type, but the current SILGen
implementation generates reabstraction thunk to convert `() -> Void`
to `() -> T` for the operation function.

Since the `T` is always `Void` for DiscardingTG, the mismatch of result
type expectation does not cause any problem on most platforms, but the
signature mismatch causes a problem on WebAssembly.

This patch introduces new builtin operations for creating discarding
task, which always takes `() -> Void` as the operation function type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
concurrency runtime Feature: umbrella label for concurrency runtime features concurrency Feature: umbrella label for concurrency language features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants