Skip to content

Implement STM builtins #1787

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
merged 7 commits into from
Jan 15, 2021
Merged

Implement STM builtins #1787

merged 7 commits into from
Jan 15, 2021

Conversation

dolio
Copy link
Contributor

@dolio dolio commented Jan 15, 2021

This merge adds STM and TVar stuff to the new runtime. The implementation is a pretty direct wrapping of GHC's API, and was more or less straight forward. Most operations are 'foreign' functions calling the GHC analogue while coercing the STM into IO if applicable. atomically is the only new primop, and is implemented by evaluating a closure with a temporary stack inside GHC's atomically implementation. This uses unsafeIOToSTM to do all the runtime operations necessary, but this should not be a problem as long as the unison code is well typed, because the only mutable state is local to the transaction.

There is a test transcript that should use all the operations currently implemented. I didn't try very hard to trigger transaction issues, but I think the implementation is sound.

Copy link
Member

@pchiusano pchiusano left a comment

Choose a reason for hiding this comment

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

Sweet! LGTM. It seems like the CI failure is spurious, it bombed during setup, fetching dependencies or something. I'm just rerunning.

@pchiusano pchiusano added the ready-to-merge Apply this to a PR and it will get merged automatically once CI passes and 1 reviewer has approved label Jan 15, 2021
@pchiusano pchiusano merged commit 45ec741 into trunk Jan 15, 2021
@pchiusano pchiusano deleted the topic/stm branch January 15, 2021 17:57
@@ -1228,13 +1253,15 @@ builtinLookup

, ("jumpCont", jumpk)

, ("IO.forkComp", fork'comp)
, ("IO.forkComp.v2", fork'comp)
Copy link
Member

Choose a reason for hiding this comment

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

@stew FYI, not sure if you were also hitting this.

@pchiusano pchiusano mentioned this pull request May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge Apply this to a PR and it will get merged automatically once CI passes and 1 reviewer has approved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants