interpret: is_alloc_live: check global allocs last · rust-lang/rust@bc135aa (original) (raw)
File tree
1 file changed
lines changed
- compiler/rustc_const_eval/src/interpret
1 file changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -830,9 +830,11 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { | ||
830 | 830 | /// [`InterpCx::get_alloc_info`] if all you need to check is whether the kind is |
831 | 831 | /// [`AllocKind::Dead`] because it doesn't have to look up the type and layout of statics. |
832 | 832 | pub fn is_alloc_live(&self, id: AllocId) -> bool { |
833 | -self.tcx.try_get_global_alloc(id).is_some() | |
834 | - | | |
833 | +self.memory.alloc_map.contains_key_ref(&id) | |
835 | 834 | | |
835 | +// We check `tcx` last as that has to acquire a lock in `many-seeds` mode. | |
836 | +// This also matches the order in `get_alloc_info`. | |
837 | + | | |
836 | 838 | } |
837 | 839 | |
838 | 840 | /// Obtain the size and alignment of an allocation, even if that allocation has |