Skip to content

Commit 1b5aa25

Browse files
authored
Merge pull request #454 from RalfJung/byte
abstract byte: typos and tweaks
2 parents 1ef1412 + 894ab16 commit 1b5aa25

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

reference/src/glossary.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
[abstract byte]: #abstract-byte
55

66
The "byte" is the smallest unit of storage in Rust.
7-
Memory allocations are thought of as storing a list of bytes, and at the lowest level each load return a list of bytes and each store takes a list of bytes and puts it into memory.
7+
Memory allocations are thought of as storing a list of bytes, and at the lowest level each load returns a list of bytes and each store takes a list of bytes and puts it into memory.
88
(The [representation relation] then defines how to convert between those lists of bytes and higher-level values such as mathematical integers or pointers.)
99

10-
However, a "byte" in the Rust Abstract Machine is more complicated than just a `u8` -- think if it as there being some extra "shadow state" that is relevant for the Abstract Machine execution (in particular, for whether this execution has UB), but that disappears when compiling the program to assembly.
11-
That's why we call it "abstract byte", to distinguish it from the physical machine byte that is represented by a `u8`.
10+
However, a "byte" in the Rust Abstract Machine is more complicated than just an integer in `0..256` -- think of it as there being some extra "shadow state" that is relevant for the Abstract Machine execution (in particular, for whether this execution has UB), but that disappears when compiling the program to assembly.
11+
That's why we call it "abstract byte", to distinguish it from the physical machine byte in `0..256`.
12+
1213
The most obvious "shadow state" is tracking whether memory is initialized.
1314
See [this blog post](https://www.ralfj.de/blog/2019/07/14/uninit.html) for details, but the gist of it is that bytes in memory are more like `Option<u8>` where `None` indicates that this byte is uninitialized.
1415
Operations like `copy` work on that representation, so if you copy from some uninitialized memory into initialized memory, the target memory becomes "de-initialized".
@@ -21,7 +22,8 @@ Without committing to the exact shape of provenance in Rust, we can therefore sa
2122
pub enum AbstractByte<Provenance> {
2223
/// An uninitialized byte.
2324
Uninit,
24-
/// An initialized byte, optionally with some provenance (if it is encoding a pointer).
25+
/// An initialized byte with a value in `0..256`,
26+
/// optionally with some provenance (if it is encoding a pointer).
2527
Init(u8, Option<Provenance>),
2628
}
2729
```

0 commit comments

Comments
 (0)