]> git.lizzy.rs Git - rust.git/commit
Auto merge of #54461 - RalfJung:pointer-provenance, r=oli-obk
authorbors <bors@rust-lang.org>
Wed, 10 Oct 2018 12:13:03 +0000 (12:13 +0000)
committerbors <bors@rust-lang.org>
Wed, 10 Oct 2018 12:13:03 +0000 (12:13 +0000)
commit2243fabd8f25c46a4a76199f10a2cd9adbb5c418
tree5c0fc6b97774927c4c2df95d0d48ec4a9143dab6
parent71d3a715721137ffc10becc10978fe038ee131ac
parentbc9435d23972aa6d2d7cc05685053b67d84d2108
Auto merge of #54461 - RalfJung:pointer-provenance, r=oli-obk

miri engine: basic support for pointer provenance tracking

This enriches pointers with a new member, `tag`, that can be used to do provenance tracking. This is a new type parameter that propagates up through everything. It defaults to `()` (no tag), which is also the value used by CTFE -- but miri will use another type.

The only actually interesting piece here, I think, is what I had to do in the memory's `get`. The problem is that `tcx` (storing the allocations for statics) uses `()` for provenance information. But the machine might need another tag. The machine has a function to do the conversion, but if a conversion actually happened, we need to store the result of this *somewhere* -- we cannot return a pointer into `tcx` as we usually would.
So I introduced `MonoHashMap` which uses `RefCell` to be able to insert new entries even when we just have a shared ref. However, it is important that we can also return shared refs into the map without holding the `RefCell` opan. This is achieved by boxing the values stored in the map, so their addresses remain stable even when the map's table gets reallocated. This is all implemented in `mono_hash_map.rs`.

NOTE: This PR also contains the commits from https://github.com/rust-lang/rust/pull/54380#issuecomment-423130753. Only the [last two commits](https://github.com/rust-lang/rust/pull/54461/files/8e74ee0998a5b11f28d61600dbb881c7168a4a40..HEAD) are new.