Skip to content

Commit 4326a44

Browse files
committed
transmutability: Mark edges by ranges, not values
In the `Tree` and `Dfa` representations of a type's layout, store byte ranges rather than needing to separately store each byte value. This permits us to, for example, represent a `u8` using a single 0..=255 edge in the DFA rather than using 256 separate edges. This leads to drastic performance improvements. For example, on the author's 2024 MacBook Pro, the time to convert the `Tree` representation of a `u64` to its equivalent DFA representation drops from ~8.5ms to ~1us, a reduction of ~8,500x. See `bench_dfa_from_tree`. Similarly, the time to execute a transmutability query from `u64` to `u64` drops from ~35us to ~1.7us, a reduction of ~20x. See `bench_transmute`.
1 parent be181dd commit 4326a44

File tree

9 files changed

+778
-161
lines changed

9 files changed

+778
-161
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4562,6 +4562,7 @@ dependencies = [
45624562
"rustc_hir",
45634563
"rustc_middle",
45644564
"rustc_span",
4565+
"smallvec",
45654566
"tracing",
45664567
]
45674568

compiler/rustc_transmute/Cargo.toml

+2-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ edition = "2024"
55

66
[dependencies]
77
# tidy-alphabetical-start
8+
itertools = "0.12"
89
rustc_abi = { path = "../rustc_abi", optional = true }
910
rustc_data_structures = { path = "../rustc_data_structures" }
1011
rustc_hir = { path = "../rustc_hir", optional = true }
1112
rustc_middle = { path = "../rustc_middle", optional = true }
1213
rustc_span = { path = "../rustc_span", optional = true }
14+
smallvec = "1.8.1"
1315
tracing = "0.1"
1416
# tidy-alphabetical-end
1517

@@ -20,8 +22,3 @@ rustc = [
2022
"dep:rustc_middle",
2123
"dep:rustc_span",
2224
]
23-
24-
[dev-dependencies]
25-
# tidy-alphabetical-start
26-
itertools = "0.12"
27-
# tidy-alphabetical-end

0 commit comments

Comments
 (0)