4 ms·
Context: MIR is an intermediate representation used by the Rust compiler; it's the final stage of Rust code before being converted to LLVM IR. Miri is an interp
by kibwen 9y ago
Context: MIR is an intermediate representation used by the Rust compiler; it's the final stage of Rust code before being converted to LLVM IR. Miri is an interpreter for MIR; it bypasses LLVM entirely and allows for direct execution of a certain subset of Rust (specifically the subset of code that can be evaluated at compile-time). Together this greatly expands the scope of constant evaluation in Rust code, granting Rust new metaprogramming faculties without requiring any new DSL (e.g. no need for C++-like template metaprogramming); just use the `const` keyword to run code at compile-time.
- tmzt 9y agoHow well would MIRI work as a generic virtual machine for fairly simple stuff. Essentially I want to compile some type-safe code from a file and run it in a safe way inside of another Rust application. I'm looking at various lua bindings as well as https://crates.io/crates/wren https://crates.io/crates/wren for this purpose, but I'm wondering if something like miri would work better since another path for compiling this language when real-time code reloading or sandboxing is not required is to translate it to Rust code and compile it with rustc, likely with a compiler plugin.
- kibwen 9y agoThat's a good question that I don't have the answer to. I'm only passingly familiar with Miri, so I can't say for certain what its intended scope is. Historically it's been developed in this repo: https://github.com/solson/miri https://github.com/solson/miri , so you could try opening an issue there and asking, though it seems as though it might soon migrate to the official rustc repo (if it hasn't already). You could also try asking around in the Rust channels (try #rust-internals) on irc.mozilla.org to get in touch with the Miri developers directly.