Skip to content

Commit c8934fc

Browse files
committed
Address review comments
1 parent fcd4a02 commit c8934fc

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Diff for: src/miri.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ The compiler needs to figure out the length of the array before being able to
2222
create items that use the type (locals, constants, function arguments, ...).
2323

2424
To obtain the (in this case empty) parameter environment, one can call
25-
`let param_env = tcx.param_env(def_id);`. The `GlobalId` needed is
25+
`let param_env = tcx.param_env(length_def_id);`. The `GlobalId` needed is
2626

2727
```rust
2828
let gid = GlobalId {
2929
promoted: None,
30-
instance: Instance::mono(def_id),
30+
instance: Instance::mono(length_def_id),
3131
};
3232
```
3333

@@ -51,8 +51,8 @@ const Foo::{{initializer}}: usize = {
5151
}
5252
```
5353

54-
Before the evaluation, a virtual memory location is created for storing the
55-
evaluation result, in this case a `vec![u8; size_of::<usize>()]`.
54+
Before the evaluation, a virtual memory location (in this case essentially a
55+
`vec![u8; 4]` or `vec![u8; 8]`) is created for storing the evaluation result.
5656

5757
At the start of the evaluation, `_0` and `_1` are
5858
`Value::ByVal(PrimVal::Undef)`. When the initialization of `_1` is invoked, the
@@ -67,7 +67,7 @@ The next statement asserts that said boolean is `0`. In case the assertion
6767
fails, its error message is used for reporting a compile-time error.
6868

6969
Since it does not fail, `Value::ByVal(PrimVal::Bytes(4054))` is stored in the
70-
virtual memory was allocated before th evaluation. `_0` always refers to that
70+
virtual memory was allocated before the evaluation. `_0` always refers to that
7171
location directly.
7272

7373
After the evaluation is done, the virtual memory allocation is interned into the
@@ -82,9 +82,9 @@ executed in order to get at something as simple as a `usize`.
8282
## Datastructures
8383

8484
Miri's core datastructures can be found in
85-
https://github.com/rust-lang/rust/blob/master/src/librustc/mir/interpret . This
86-
is mainly the error enum and the `Value` and `PrimVal` types. A `Value` can be
87-
either `ByVal` (a single `PrimVal`), `ByValPair` (two `PrimVal`s, usually fat
85+
[librustc/mir/interpret](https://github.com/rust-lang/rust/blob/master/src/librustc/mir/interpret).
86+
This is mainly the error enum and the `Value` and `PrimVal` types. A `Value` can
87+
be either `ByVal` (a single `PrimVal`), `ByValPair` (two `PrimVal`s, usually fat
8888
pointers or two element tuples) or `ByRef`, which is used for anything else and
8989
refers to a virtual allocation. These allocations can be accessed via the
9090
methods on `tcx.interpret_interner`.
@@ -112,7 +112,7 @@ to a pointer to `b`.
112112

113113
Although the main entry point to constant evaluation is the `tcx.const_eval`
114114
query, there are additional functions in
115-
https://github.com/rust-lang/rust/blob/master/src/librustc_mir/interpret/const_eval
115+
[librustc_mir/interpret/const_eval.rs](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/interpret/const_eval.rs)
116116
that allow accessing the fields of a `Value` (`ByRef` or otherwise). You should
117117
never have to access an `Allocation` directly except for translating it to the
118118
compilation target (at the moment just LLVM).
@@ -123,7 +123,7 @@ function with no arguments, except that constants do not allow local (named)
123123
variables at the time of writing this guide.
124124

125125
A stack frame is defined by the `Frame` type in
126-
https://github.com/rust-lang/rust/blob/master/src/librustc_mir/interpret/eval_context.rs
126+
[librustc_mir/interpret/eval_context.rs](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/interpret/eval_context.rs)
127127
and contains all the local
128128
variables memory (`None` at the start of evaluation). Each frame refers to the
129129
evaluation of either the root constant or subsequent calls to `const fn`. The
@@ -135,7 +135,7 @@ The frames are just a `Vec<Frame>`, there's no way to actually refer to a
135135
memory that can be referred to are `Allocation`s.
136136

137137
Miri now calls the `step` method (in
138-
https://github.com/rust-lang/rust/blob/master/src/librustc_mir/interpret/step.rs
138+
[librustc_mir/interpret/step.rs](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/interpret/step.rs)
139139
) until it either returns an error or has no further statements to execute. Each
140140
statement will now initialize or modify the locals or the virtual memory
141141
referred to by a local. This might require evaluating other constants or

0 commit comments

Comments
 (0)