-
Notifications
You must be signed in to change notification settings - Fork 277
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
[feature] #2491: Enum support in FFi #2625
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
the
iroha2-dev
The re-implementation of a BFT hyperledger in RUST
label
Aug 15, 2022
mversic
commented
Aug 15, 2022
mversic
commented
Aug 15, 2022
Erigara
reviewed
Aug 16, 2022
Erigara
reviewed
Aug 17, 2022
appetrosyan
reviewed
Aug 22, 2022
mversic
force-pushed
the
ffi_enum
branch
3 times, most recently
from
September 8, 2022 23:56
e58b137
to
1922773
Compare
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
Erigara
reviewed
Sep 9, 2022
This was referenced Sep 26, 2022
Erigara
previously approved these changes
Sep 27, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Closed
mversic
force-pushed
the
ffi_enum
branch
2 times, most recently
from
September 27, 2022 15:40
c391cd2
to
aff21d0
Compare
appetrosyan
reviewed
Sep 27, 2022
mversic
force-pushed
the
ffi_enum
branch
4 times, most recently
from
September 28, 2022 14:38
6746ab8
to
edaea84
Compare
This was referenced Sep 28, 2022
Signed-off-by: Marin Veršić <[email protected]> add support for data-carrying enums Signed-off-by: Marin Veršić <[email protected]> refactor ffi library implementation Signed-off-by: Marin Veršić <[email protected]> improve wasm types FFI serialization Signed-off-by: Marin Veršić <[email protected]> introduce Opaque and out-pointers in IR Signed-off-by: Marin Veršić <[email protected]> introduce Transparent in IR, use it for fieldless enums Signed-off-by: Marin Veršić <[email protected]> remove Transmute in favor of Transparent Signed-off-by: Marin Veršić <[email protected]> Extend IR, make generic impls for slices and vectors Signed-off-by: Marin Veršić <[email protected]> add implementation for data-carrying enum Signed-off-by: Marin Veršić <[email protected]> separate FfiType and FfiConvert traits Signed-off-by: Marin Veršić <[email protected]> implement support for arrays Signed-off-by: Marin Veršić <[email protected]> prevent use-after-free in FFI method return Signed-off-by: Marin Veršić <[email protected]> fix review comments Signed-off-by: Marin Veršić <[email protected]>
Erigara
approved these changes
Sep 29, 2022
appetrosyan
approved these changes
Sep 29, 2022
appetrosyan
pushed a commit
that referenced
this pull request
Oct 7, 2022
Signed-off-by: Marin Versic <[email protected]>
appetrosyan
pushed a commit
that referenced
this pull request
Oct 7, 2022
Signed-off-by: Marin Versic <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Change
wasm
feature flag fortarget_type
. After some discussion with @Erigara this was decided to be preferableIntoFfi
andTryFromReprC
withFfiType
andFfiConvert
traits. Previous separation couldn't be worked with mostly due to conflicting requirements on lifetimes on data carrying enums. Maybe GATs would have been of help here, not sure anymore. If neededFfiConvert
can be split intoTryFromFfi
/IntoFfi
ReprC
types (namelySliceRef
/SliceMut
). It was too noisy and difficult to deal with but I think it can (should?) be reintroduced nownon_robust_ref_mut
feature flag. Might be useful to disallow mutation for non-robust typesNonLocal
Type challenges
There is no specialization or HKTs in
Rust
, so it's very difficult to properly delineate type categories. But it can be emulated in the type system. This is what theIr
trait is for.Rust
type is first wrapped in the correctIr
type after which static dispatch on IR marker types provides an optimal(zero-copy when possible) implementation ofFFIType
.Issue
Closes #2491 #2629
Benefits
optimal conversion, enums support
Possible Drawbacks
I'm not sure if it's more complex than before of just a different perspective
Usage Examples or Tests [optional]
This is what a conversion for data-carrying enum would produce (it is not even required it is
repr(C)
:There was a suggestion to use a different enum representation. It can be modified. At the moment I found this easier to implement
Alternate Designs [optional]
I've tried some but all failed in expresivity