near / wasmtime

Standalone JIT-style runtime for WebAssembly, using Cranelift
https://wasmtime.dev/
Apache License 2.0
3 stars 4 forks source link

Print consistent names for zkASM `Inst`s #217

Open mooori opened 7 months ago

mooori commented 7 months ago

Benchmarking requires functionality to print the names of Inst variants. This functionality should be re-used as pointed out by @nagisa in this comment:

[...] I think we should also consider reusing this for print_with_state to maintain consistent names across various places where we print these instructions. This shouldn't be too hard (although the diff will not be minimal) and can be achieved roughly through:

let mut output = String::with_capacity(32);
output.push_str(self.print_name());
match self {
    Inst::Udf { trap_code } => write!(&mut output, "##trap_code={trap_code}"),
    ...
}

This should also reveal that e.g. Inst::Select is actually considered multiple different instructions depending on a ty field. It might or might not be useful to split them out for histogram purposes as well.