Does anybody know of any interpreters that closely follow the shape and structure of the specification? My goal is to pretty much use it as a reference implementation for some tests after modifying it with changes to the spec that I have in mind. I want to avoid missing implementation-specific details with the modifications, and so for that reason specifically it would be nice if the implementation was mirroring the spec as close to 1:1 as possible, including the instruction reduction mechanism used in the spec. As far as Rust implementations go, wain seems to fit the bill the best so far, but that implementation has chosen to eschew the reduction approach for the more straightforward loop { match { ... } }
.
@nagisa the spec repository itself has the reference interpreter, which seems to be the best fit I can think of for your request; it's written in a way that basically mirrors the spec's reduction rules into OCaml
@Conrad Watt has done work to make it fast with a few tweaks (otherwise it has some unfortunate quadratic behavior) and we use that version as an oracle for fuzzing
just to add, you should _definitely_ use the unmodified reference interpreter if you can get away with it, rather than my fork, which contains code generated using a theorem prover and isn't really human-readable
Yeah performance is of little concern in my case, integrability into a typical Rust crate’s test suite and ability to modify it is however. I think might be able to live with ocaml as a dep, but I’ll need to see if I can get up to speed with the impl reasonably quickly.
It would be pretty useful to have the OCaml based Wasm spec interpreter as a Rust crate on crates.io. I see it fruitful for things like fuzz testing Wasm validation and runtime execution against the Wasm spec interpreter.
@Hero Bird, with a little bit of work, the wasm-spec-interpreter
crate in Wasmtime (here) could be adapted and published on crates.io. Are you interested in that?
@Andrew Brown If the BytecodeAlliance team appreciates the idea I'd definitely be interested in publishing the wasm-spec-interpreter
to crates.io. I could really use this for wasmi
. :)
Well I think it's a fine idea personally, I think there's a couple of things to figure out:
I will bring this up in the Cranelift meeting in a few minutes to see what people think
Okay thanks a lot for this information and thanks for bringing up the idea at the next Cranelift meeting! :)
I'd just make the BytecodeAlliance the publisher of the crate as with all other BytecodeAlliance crates. Please keep me updated about this.
Maybe having an issue where we can discuss this would be valuable once the decision for this idea has been made.
Sorry if I've misunderstood, but will this be discussed at the Wasmtime meeting on the 18th? I can dial in.
EDIT: ah, I guess I missed the relevant call, no worries :)
Sure, I can add it as an agenda topic for the Wasmtime meeting as well
btw, the version of the interpreter I maintain has a command line switch that lets you use the "original" interpreter definitions
so there wouldn't be a strict need for any further configuration on that front
(although maybe some work is needed in the top-level interpret.ml
file of the crate to expose this)
Where can I find a link to @Conrad Watt 's interpreter. Is this interpreter also meant to be a spec reference implementation of Wasm?
link: https://github.com/conrad-watt/spec/tree/wasmtime_fuzzing/interpreter
its story is a little more complicated - the interpreter is based on a logical model of the spec written in the Isabelle theorem prover - the model is the "reference", and the interpreter isn't meant to be directly readable, but instead trusted because there's a proof that it's correct wrt the model
paper: https://vtss.doc.ic.ac.uk/publications/Watt2021Two.pdf
this approach means I can implement optimisations without breaking the "trust story"
Ok, here is the agenda topic for the 18th: https://github.com/bytecodealliance/meetings/pull/12. @Hero Bird, can you make it to that meeting as well?
@Conrad Watt Thanks for the link and explanations!
@Andrew Brown Never took part in such a meeting but I guess it is about time, right?
Unfortunately I've just found out that I'll only be able to join the meeting for the first 30 minutes. I'm very sorry about this, and if it turns out not to be enough time I'm happy to call/message anyone who's interested out-of-band.
@Andrew Brown Do I need to contact someone in order to participate in the meeting later or am I already signed up?
Not totally sure; perhaps contact @fitzgen (he/him)?
okay will do
I've created https://github.com/bytecodealliance/wasm-spec-interpreter for a repo here
Maybe I am just stupid but GitHub does not allow me to fork the repo or create a bare PR for it because the repo is empty.
I'll move the code there in a few minutes so we can get started...
@Robin Freyler, what is your GitHub handle?
never mind, I think I figured it out
@Robin Freyler, @Conrad Watt, @Alex Crichton: I could use some reviews on the setup of that repository, https://github.com/bytecodealliance/wasm-spec-interpreter/pulls. (Not sure what I did wrong in the CI infrastructure one because I thought it would run the CI even in the PR; maybe we need to merge it first to activate GitHub Actions?).
you'll need to merge to main
to trigger CI on future PRs
CI added just in a PR for the first time doesn't trigger a run automatically
Last updated: Nov 22 2024 at 16:03 UTC