feat(ext/ffi): Struct-by-value passing #17098
Closed
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.
Rebased @DjDeveloperr 's #15060 PR and solved some issues regarding struct passing in asynchronous FFI calls (libffi changes required, which is why the dependency is updated) and nested struct alignment calculation.
Proper tests for the feature are implemented, and the branch has also seen live use as the test-bed for my libclang bindings, where it has functioned without any hiccups. The branch has also received some brute-force memory leak testing through a while-loop of calling a
Deno.UnsafeCallback
using aDeno.UnsafeFnPointer
with both the parameter and return value of the function being a struct. Memory usage of the deno process does not increase at all, staying nicely at 0.3% even after >1 minute of 100% CPU usage.Co-authored-by: @DjDeveloperr ([email protected])