Skip to content
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

Evaluate the layouts for the tasks at compile time #30

Merged
merged 4 commits into from
Jul 7, 2022
Merged

Evaluate the layouts for the tasks at compile time #30

merged 4 commits into from
Jul 7, 2022

Conversation

notgull
Copy link
Member

@notgull notgull commented Jul 4, 2022

Thank you for the challenge, @michaelwoerister

This pull request adds new internal functionality to async-task that, rather than computing task_layout() at runtime, turns it into an associated const on RawTask. Safety guarantees are still upheld; the program will still abort() at runtime with an invalid task layout.

Note that this bumps up the MSRV to 1.47.0, as that is when the checked_* family of functions were stabilized as const-evalutated. @taiki-e has mentioned that they are comfortable bumping the MSRV to up to 1.48.0, so I hope this shouldn't be an issue.

@notgull
Copy link
Member Author

notgull commented Jul 4, 2022

Note that this may obsolete #29, since the layout is now essentially already cached into each of the VTable functions

@michaelwoerister
Copy link
Contributor

Nice! Great idea to go through an associated const. Thanks for looking into it, @notgull :)

An adapted version of #29 will still be necessary for debuggability (because rustc apparently does not emit debuginfo for associated consts) -- but now we can just put a &'static Self::TASK_LAYOUT reference into TaskVTable instead of storing something in Header.

So, I'd be in favor of merging this PR first.

Copy link
Collaborator

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

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

Thanks!

@taiki-e taiki-e merged commit 8a6ffad into smol-rs:master Jul 7, 2022
@notgull notgull deleted the const-layout branch July 7, 2022 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants