Enumerate all host calls in wasmtime_environ::HostCall#9743
Merged
alexcrichton merged 2 commits intobytecodealliance:mainfrom Dec 5, 2024
Merged
Enumerate all host calls in wasmtime_environ::HostCall#9743alexcrichton merged 2 commits intobytecodealliance:mainfrom
wasmtime_environ::HostCall#9743alexcrichton merged 2 commits intobytecodealliance:mainfrom
Conversation
This commit is a continuation of the plan of implementing host calls in Pulley through bytecodealliance#9665, bytecodealliance#9675, and bytecodealliance#9693. Here the `Compiler::call_indirect_host` method is updated to take a new type, `HostCall`, which indicates what type of host call is being performed. This is then serialized to a 32-bit integer which will be present in the pulley instruction being generated. This 32-bit integer will then be used to perform a dispatch (the dispatch is left for a future PR with more Pulley integration). This new `HostCall` structure is defined with `BuiltinFunctionIndex` internally. Additionally a new `ComponentBuiltinFunctionIndex` is added to enumerate the same set of indexes for components as well. Along the way the split between component transcoders/builtins were removed and they're now all lumped together in one macro for builtins. (no need to have two separate macros). This new `HostCall` is used to implement the `call_indirect_host` instruction for Pulley to fill out an unimplemented piece of code.
Member
Yessssss |
This was referenced Dec 5, 2024
fitzgen
reviewed
Dec 5, 2024
Member
fitzgen
left a comment
There was a problem hiding this comment.
LGTM modulo a nitpick around naming
crates/cranelift/src/func_environ.rs
Outdated
| Self { | ||
| types: BuiltinFunctionSignatures::new(compiler), | ||
| builtins: [None; BuiltinFunctionIndex::builtin_functions_total_number() as usize], | ||
| builtins: [None; BuiltinFunctionIndex::max() as usize], |
Member
There was a problem hiding this comment.
Nitpick: If max returns the maximum index then this should be max + 1. If max returns the number of builtins then we should rename it to len or count or something.
Ditto just above.
crates/environ/src/builtin.rs
Outdated
| ) => { | ||
| /// Returns the total number of builtin functions. | ||
| pub const fn builtin_functions_total_number() -> u32 { | ||
| pub const fn max() -> u32 { |
Member
There was a problem hiding this comment.
Yeah let's call this count or len or something instead of max.
fitzgen
approved these changes
Dec 5, 2024
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 is a continuation of the plan of implementing host calls in Pulley through #9665, #9675, and #9693. Here the
Compiler::call_indirect_hostmethod is updated to take a new type,HostCall, which indicates what type of host call is being performed. This is then serialized to a 32-bit integer which will be present in the pulley instruction being generated. This 32-bit integer will then be used to perform a dispatch (the dispatch is left for a future PR with more Pulley integration).This new
HostCallstructure is defined withBuiltinFunctionIndexinternally. Additionally a newComponentBuiltinFunctionIndexis added to enumerate the same set of indexes for components as well. Along the way the split between component transcoders/builtins were removed and they're now all lumped together in one macro for builtins. (no need to have two separate macros).This new
HostCallis used to implement thecall_indirect_hostinstruction for Pulley to fill out an unimplemented piece of code.