khagankhan opened PR #11713 from khagankhan:rec-mutators to bytecodealliance:main:
- Add a function import that takes a
structrefargument to our Wasm binary skeleton- Add a fuzzer op that calls that new function
- Add a function import for each defined struct type that takes a reference of that type specifically
- Add a fuzzer op that calls these new typed functions
- Generic
(type (;4;) (func (param (ref any))))is called afterStructNewop instead ofDropto observe that specific struct and also maintain stack discipline.- Typed versions are called with specific structs of the types
cc @fitzgen @eeide
khagankhan requested alexcrichton for a review on PR #11713.
khagankhan requested wasmtime-fuzz-reviewers for a review on PR #11713.
khagankhan updated PR #11713.
github-actions[bot] commented on PR #11713:
Subscribe to Label Action
cc @fitzgen
<details>
This issue or pull request has been labeled: "fuzzing"Thus the following users have been cc'd because of the following labels:
- fitzgen: fuzzing
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
fitzgen submitted PR review:
Looks good with the below addressed, thanks!
fitzgen created PR review comment:
Would be nice to have a single-sentence comment for readers here describing what this code is doing, so that they don't have to scrutinize it to figure out what is going on. Something like
For each of our concrete struct types, define a function import that takes an argument of that concrete type.
fitzgen created PR review comment:
Not necessary in this PR, but it would probably be easier/cleaner down the line to switch from constants to using the
wasm_encoder::{Type,Func}Section::lenmethods to keep track of these things, so that we don't need to update these constants every time we unconditionally add a new type/function.https://docs.rs/wasm-encoder/latest/wasm_encoder/struct.TypeSection.html#method.len
fitzgen created PR review comment:
You can avoid the wonky
.last()stuff by pushing the name after defining the import:let name = format!("take_struct_{concrete}"); imports.import( "", &name, EntityType::Function(ty_idx), ); typed_names.push(name);
fitzgen created PR review comment:
As mentioned earlier, things get a bit simpler and less brittle if we use the
lenfunctions on the sections that define index spaces:let mut functions = FunctionSection::new(); let mut exports = ExportSection::new(); // Define the "run" function export. let run_index = functions.len(); functions.function(1); exports.export("run", ExportKind::Func, run_index);I think it is worth doing this to avoid adding more opaque
<constant> + <count>incantations.
fitzgen created PR review comment:
Empty comment at the end of line?
fitzgen created PR review comment:
Nothing to change in this PR, but I want to point out that these emitted instruction sequences are not our ideal end state. We want to separate
struct.newfrom variouscalls anddrops and have the existingTableOp::Dropbe used to drop struct refs and we want thetake_*calls to take a struct ref from the stack, not create a new one to pass to the import. This will require updating the abstract stack representation to track types, however, so it should be left to a follow up PR.
khagankhan submitted PR review.
khagankhan created PR review comment:
Yes, I agree!
khagankhan commented on PR #11713:
Thanks @fitzgen. Working on them!
khagankhan updated PR #11713.
khagankhan updated PR #11713.
khagankhan commented on PR #11713:
@fitzgen @eeide
Ready for review
Changes
- Split
table_ops.rsinto separate modules and renamed toGcOpswhere applicable- Addressed prior review feedback
- Ran the fuzzer for ~1 hour and fixed generation bugs discovered
fitzgen commented on PR #11713:
@khagankhan can you delay the split into multiple modules for a follow up PR that contains nothing but the code motion? Otherwise it makes reading and interpreting the diff very hard, as a reviewer.
khagankhan commented on PR #11713:
@fitzgen I can do that. However, if you want I can point the code that needs review (that changed other than names)
fitzgen commented on PR #11713:
I'd prefer to just review one change at a time instead of multiple things, so please split up the PR. Thanks!
khagankhan commented on PR #11713:
Sure thing! o7
khagankhan updated PR #11713.
khagankhan updated PR #11713.
khagankhan commented on PR #11713:
@fitzgen Reverted! Ready for review
fitzgen submitted PR review:
Thanks!
fitzgen merged PR #11713.
Last updated: Dec 06 2025 at 06:05 UTC