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
This draft PR serves as an experimental validation to assess whether the proposed design changes to the wasm64 system API change can seamlessly integrate into Rust CDK.
The system API text and the bindgen
This part is mainly about the
ic0
crate.ic0.txt
: The notable change in the system API text is the replacement ofi32
pointers withI ∈ {i32, i64}
.ic0build.rs
: this bindings generation script was modified accordingly. It replaces theI
withisize
.ic.rs
: This is the generated Rust unsafe binding. The conditional compilation now uses#[cfg(target_family = "wasm")]
which will work with allwasm32-*
andwasm64-*
targets.Handle the
env: i32
parameterIn the existing wasm32-only scenario, the
env: i32
parameters incall_new()
andcall_on_cleanup()
are used as raw pointers (32-bit).When it comes to wasm64,
env: i32
can no longer be used as pointers (64-bit) anymore. We have to introduce an extra indirection which maps from 32-bit integers to 64-bit pointers.slotmap
forkI forked the$2^{16}-1 = 65525$ open calls. The number can be expanded by doing more modification to the
slotmap
crate, halve the bit-width ofKeyData
fields (from u32 to u16), so that the key can be lossless converted to/from u32. This introduces a limitation wherein there cannot be more thanslotmap
crate. But the limitation itself is inevitable.The indirection
Test
Given that the replica hasn't yet adopted wasm64 support, I continue to utilize the wasm32 target to verify the functionality of the slotmap indirection.
Now that all the existing tests pass, it proves the functionality.
Future
The following questions remain open for future exploration: