Implement dup-family functions #832
Merged
Merged
Conversation
pchickey
approved these changes
Jul 17, 2026
alexcrichton
enabled auto-merge (squash)
July 17, 2026 17:18
This commit builds on the work of WebAssembly#822 to implement `dup`-style functions. Notably `dup`, `dup2`, `dup3`, and `F_DUPFD{,_CLOEXEC}` are now implemented for wasip2/wasip3 targets. The wasip1 target is left unmodified here. The goal of this commit is to unblock more tests being run in Python upstream where a number rely on these functions. With the reference counting in WebAssembly#822 the functions are relatively easy to implement, although this required refactoring the descriptor table itself to support these operations. Previously the descriptor table allocated in a LIFO manner but this has been replaced with a POSIX-compliant lowest-value-returned instead. Closes WebAssembly#802
This file contains hidden or 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
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.
This commit builds on the work of #822 to implement
dup-stylefunctions. Notably
dup,dup2,dup3, andF_DUPFD{,_CLOEXEC}arenow implemented for wasip2/wasip3 targets. The wasip1 target is left
unmodified here. The goal of this commit is to unblock more tests being
run in Python upstream where a number rely on these functions. With the
reference counting in #822 the functions are relatively easy to
implement, although this required refactoring the descriptor table
itself to support these operations.
Previously the descriptor table allocated in a LIFO manner but this has
been replaced with a POSIX-compliant lowest-value-returned instead.
Closes #802