Skip to content

gen-guest-c: scalar enum result -> bool return, ok & err ptrs#450

Merged
guybedford merged 6 commits intomainfrom
c-result-enum
Dec 9, 2022
Merged

gen-guest-c: scalar enum result -> bool return, ok & err ptrs#450
guybedford merged 6 commits intomainfrom
c-result-enum

Conversation

@guybedford
Copy link
Copy Markdown
Contributor

@guybedford guybedford commented Dec 9, 2022

This updates the result error enum handling to return a boolean instead of a flattened enum, with two possible return pointers - one for the success value and one for the error value.

It does seem slightly higher bandwidth in comparison to what we had before, in that there are three values and three writes instead of two values and two writes now.

I'm going to test out this diff in the js-compute-runtime bindings work, and see how noisy it looks.

The alternative is to completely unflatten the result and just have the double pointer situation from result -> ok / err pointer writes... still somewhat on the fence between the two approaches.

Fixes #449.

Copy link
Copy Markdown
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

I think it'd also be reasonable to take a union out-ptr (C union) for the return payload as well rather than two, but either way works IMO.

@guybedford
Copy link
Copy Markdown
Contributor Author

I've updated the PR in the latest commit to avoid double writing to both the err and ok return pointers using a singular store function approach.

@guybedford guybedford merged commit d47b6c5 into main Dec 9, 2022
@guybedford guybedford deleted the c-result-enum branch December 9, 2022 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gen-guest-c: remove result enum flattening

2 participants