Skip to content

Commit ff10b1d

Browse files
authored
don't refer to the compile-time interpreter as "Miri" (rust-lang#1471)
1 parent b632326 commit ff10b1d

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

src/doc/rustc-dev-guide/book.toml

+1
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ warning-policy = "error"
4343
[output.html.redirect]
4444
"/compiletest.html" = "tests/compiletest.html"
4545
"/diagnostics/sessiondiagnostic.html" = "diagnostics/diagnostic-structs.html"
46+
"/miri.html" = "const-eval/interpret.html"

src/doc/rustc-dev-guide/src/SUMMARY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
- [MIR optimizations](./mir/optimizations.md)
153153
- [Debugging](./mir/debugging.md)
154154
- [Constant evaluation](./const-eval.md)
155-
- [miri const evaluator](./miri.md)
155+
- [Interpreter](./const-eval/interpret.md)
156156
- [Monomorphization](./backend/monomorph.md)
157157
- [Lowering MIR](./backend/lowering-mir.md)
158158
- [Code Generation](./backend/codegen.md)

src/doc/rustc-dev-guide/src/appendix/glossary.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Term | Meaning
3636
<span id="infcx">infcx</span> &nbsp; | The type inference context (`InferCtxt`). (see `rustc_middle::infer`)
3737
<span id="inf-var">inference variable</span> &nbsp; | When doing type or region inference, an "inference variable" is a kind of special type/region that represents what you are trying to infer. Think of X in algebra. For example, if we are trying to infer the type of a variable in a program, we create an inference variable to represent that unknown type.
3838
<span id="intern">intern</span> &nbsp; | Interning refers to storing certain frequently-used constant data, such as strings, and then referring to the data by an identifier (e.g. a `Symbol`) rather than the data itself, to reduce memory usage and number of allocations. See [this chapter](../memory.md) for more info.
39+
<span id="interpreter">interpreter</span> &nbsp; | The heart of const evaluation, running MIR code at compile time. ([see more](../const-eval/interpret.md))
3940
<span id="intrinsic">intrinsic</span> &nbsp; | Intrinsics are special functions that are implemented in the compiler itself but exposed (often unstably) to users. They do magical and dangerous things. (See [`std::intrinsics`](https://doc.rust-lang.org/std/intrinsics/index.html))
4041
<span id="ir">IR</span> &nbsp; | Short for Intermediate Representation, a general term in compilers. During compilation, the code is transformed from raw source (ASCII text) to various IRs. In Rust, these are primarily HIR, MIR, and LLVM IR. Each IR is well-suited for some set of computations. For example, MIR is well-suited for the borrow checker, and LLVM IR is well-suited for codegen because LLVM accepts it.
4142
<span id="irlo">IRLO</span> &nbsp; | `IRLO` or `irlo` is sometimes used as an abbreviation for [internals.rust-lang.org](https://internals.rust-lang.org).
@@ -47,7 +48,7 @@ Term | Meaning
4748
<span id="llvm">[LLVM]</span> &nbsp; | (actually not an acronym :P) an open-source compiler backend. It accepts LLVM IR and outputs native binaries. Various languages (e.g. Rust) can then implement a compiler front-end that outputs LLVM IR and use LLVM to compile to all the platforms LLVM supports.
4849
<span id="memoization">memoization</span> &nbsp; | The process of storing the results of (pure) computations (such as pure function calls) to avoid having to repeat them in the future. This is typically a trade-off between execution speed and memory usage.
4950
<span id="mir">MIR</span> &nbsp; | The Mid-level IR that is created after type-checking for use by borrowck and codegen. ([see more](../mir/index.md))
50-
<span id="miri">miri</span> &nbsp; | An interpreter for MIR used for constant evaluation. ([see more](../miri.md))
51+
<span id="miri">Miri</span> &nbsp; | A tool to detect Undefined Behavior in (unsafe) Rust code. ([see more](https://github.com/rust-lang/miri))
5152
<span id="mono">monomorphization</span> &nbsp; | The process of taking generic implementations of types and functions and instantiating them with concrete types. For example, in the code we might have `Vec<T>`, but in the final executable, we will have a copy of the `Vec` code for every concrete type used in the program (e.g. a copy for `Vec<usize>`, a copy for `Vec<MyStruct>`, etc).
5253
<span id="normalize">normalize</span> &nbsp; | A general term for converting to a more canonical form, but in the case of rustc typically refers to [associated type normalization](../traits/goals-and-clauses.md#normalizeprojection---type).
5354
<span id="newtype">newtype</span> &nbsp; | A wrapper around some other type (e.g., `struct Foo(T)` is a "newtype" for `T`). This is commonly used in Rust to give a stronger type for indices.

src/doc/rustc-dev-guide/src/const-eval.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,10 @@ As a consequence, all decoding of `ValTree` must happen by matching on the type
7777
decisions depending on that. The value itself gives no useful information without the type that
7878
belongs to it.
7979

80-
Other constants get represented as [`ConstValue::Scalar`]
81-
or [`ConstValue::Slice`] if possible. This means that the `const_eval_*`
82-
functions cannot be used to create miri-pointers to the evaluated constant.
83-
If you need the value of a constant inside Miri, you need to directly work with
84-
[`const_to_op`].
80+
Other constants get represented as [`ConstValue::Scalar`] or
81+
[`ConstValue::Slice`] if possible. These values are only useful outside the
82+
compile-time interpreter. If you need the value of a constant during
83+
interpretation, you need to directly work with [`const_to_op`].
8584

8685
[`GlobalId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/interpret/struct.GlobalId.html
8786
[`ConstValue::Scalar`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/interpret/value/enum.ConstValue.html#variant.Scalar

src/doc/rustc-dev-guide/src/miri.md src/doc/rustc-dev-guide/src/const-eval/interpret.md

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
# Miri
1+
# Interpreter
22

33
<!-- toc -->
44

5-
The Miri (**MIR** **I**nterpreter) engine is a virtual machine for executing MIR without
6-
compiling to machine code. It is usually invoked via `tcx.const_eval_*` functions.
7-
In the following, we will refer to the Miri engine as just "Miri", but note that
8-
there also is a stand-alone
9-
[tool called "Miri"](https://github.com/rust-lang/miri/) that is based on the
10-
engine (sometimes referred to as Miri-the-tool to disambiguate it from the
11-
engine).
5+
The interpreter is a virtual machine for executing MIR without compiling to
6+
machine code. It is usually invoked via `tcx.const_eval_*` functions. The
7+
interpreter is shared between the compiler (for compile-time function
8+
evaluation, CTFE) and the tool [Miri](https://github.com/rust-lang/miri/), which
9+
uses the same virtual machine to detect Undefined Behavior in (unsafe) Rust
10+
code.
1211

1312
If you start out with a constant:
1413

@@ -98,7 +97,7 @@ further queries need to be executed in order to get at something as simple as a
9897
`usize`.
9998

10099
Future evaluations of the same constants will not actually invoke
101-
Miri, but just use the cached result.
100+
the interpreter, but just use the cached result.
102101

103102
[`Operand`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_const_eval/interpret/enum.Operand.html
104103
[`Immediate`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_const_eval/interpret/enum.Immediate.html
@@ -108,7 +107,7 @@ Miri, but just use the cached result.
108107

109108
## Datastructures
110109

111-
Miri's outside-facing datastructures can be found in
110+
The interpreter's outside-facing datastructures can be found in
112111
[rustc_middle/src/mir/interpret](https://github.com/rust-lang/rust/blob/master/compiler/rustc_middle/src/mir/interpret).
113112
This is mainly the error enum and the [`ConstValue`] and [`Scalar`] types. A
114113
`ConstValue` can be either `Scalar` (a single `Scalar`, i.e., integer or thin
@@ -124,7 +123,7 @@ in an `Option<u64>` yielding the `Scalar` if possible.
124123

125124
## Memory
126125

127-
To support any kind of pointers, Miri needs to have a "virtual memory" that the
126+
To support any kind of pointers, the interpreter needs to have a "virtual memory" that the
128127
pointers can point to. This is implemented in the [`Memory`] type. In the
129128
simplest model, every global variable, stack variable and every dynamic
130129
allocation corresponds to an [`Allocation`] in that memory. (Actually using an
@@ -164,7 +163,7 @@ track of which of its bytes are initialized.
164163

165164
### Global memory and exotic allocations
166165

167-
`Memory` exists only during the Miri evaluation; it gets destroyed when the
166+
`Memory` exists only during evaluation; it gets destroyed when the
168167
final value of the constant is computed. In case that constant contains any
169168
pointers, those get "interned" and moved to a global "const eval memory" that is
170169
part of `TyCtxt`. These allocations stay around for the remaining computation
@@ -190,10 +189,10 @@ bytes of its value.
190189

191190
### Pointer values vs Pointer types
192191

193-
One common cause of confusion in Miri is that being a pointer *value* and having
192+
One common cause of confusion in the interpreter is that being a pointer *value* and having
194193
a pointer *type* are entirely independent properties. By "pointer value", we
195194
refer to a `Scalar::Ptr` containing a `Pointer` and thus pointing somewhere into
196-
Miri's virtual memory. This is in contrast to `Scalar::Raw`, which is just some
195+
the interpreter's virtual memory. This is in contrast to `Scalar::Raw`, which is just some
197196
concrete integer.
198197

199198
However, a variable of pointer or reference *type*, such as `*const T` or `&T`,
@@ -214,7 +213,7 @@ that allow accessing the fields of a `ConstValue` (`ByRef` or otherwise). You sh
214213
never have to access an `Allocation` directly except for translating it to the
215214
compilation target (at the moment just LLVM).
216215

217-
Miri starts by creating a virtual stack frame for the current constant that is
216+
The interpreter starts by creating a virtual stack frame for the current constant that is
218217
being evaluated. There's essentially no difference between a constant and a
219218
function with no arguments, except that constants do not allow local (named)
220219
variables at the time of writing this guide.
@@ -231,7 +230,7 @@ The frames are just a `Vec<Frame>`, there's no way to actually refer to a
231230
`Frame`'s memory even if horrible shenanigans are done via unsafe code. The only
232231
memory that can be referred to are `Allocation`s.
233232

234-
Miri now calls the `step` method (in
233+
The interpreter now calls the `step` method (in
235234
[rustc_const_eval/src/interpret/step.rs](https://github.com/rust-lang/rust/blob/master/compiler/rustc_const_eval/src/interpret/step.rs)
236235
) until it either returns an error or has no further statements to execute. Each
237236
statement will now initialize or modify the locals or the virtual memory

0 commit comments

Comments
 (0)