diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-02-14 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-02-16 23:34:50 +0100 |
| commit | 6c9d7fbeedd31398f363185106da292c2cdccb7f (patch) | |
| tree | d8d72580eae457df02e7dd2a5c8176f499a55344 | |
| parent | a143517d44cac50b20cbd3a0b579addab40dd399 (diff) | |
| download | rust-6c9d7fbeedd31398f363185106da292c2cdccb7f.tar.gz rust-6c9d7fbeedd31398f363185106da292c2cdccb7f.zip | |
Add size assertions for interpreter data structures
| -rw-r--r-- | compiler/rustc_mir/src/interpret/operand.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_mir/src/interpret/place.rs | 15 |
2 files changed, 24 insertions, 0 deletions
diff --git a/compiler/rustc_mir/src/interpret/operand.rs b/compiler/rustc_mir/src/interpret/operand.rs index 88236458a21..96fe22cab19 100644 --- a/compiler/rustc_mir/src/interpret/operand.rs +++ b/compiler/rustc_mir/src/interpret/operand.rs @@ -32,6 +32,9 @@ pub enum Immediate<Tag = ()> { ScalarPair(ScalarMaybeUninit<Tag>, ScalarMaybeUninit<Tag>), } +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(Immediate, 56); + impl<Tag> From<ScalarMaybeUninit<Tag>> for Immediate<Tag> { #[inline(always)] fn from(val: ScalarMaybeUninit<Tag>) -> Self { @@ -92,6 +95,9 @@ pub struct ImmTy<'tcx, Tag = ()> { pub layout: TyAndLayout<'tcx>, } +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(ImmTy<'_>, 72); + impl<Tag: Copy> std::fmt::Display for ImmTy<'tcx, Tag> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { /// Helper function for printing a scalar to a FmtPrinter @@ -156,6 +162,9 @@ pub struct OpTy<'tcx, Tag = ()> { pub layout: TyAndLayout<'tcx>, } +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(OpTy<'_, ()>, 80); + impl<'tcx, Tag> std::ops::Deref for OpTy<'tcx, Tag> { type Target = Operand<Tag>; #[inline(always)] diff --git a/compiler/rustc_mir/src/interpret/place.rs b/compiler/rustc_mir/src/interpret/place.rs index efde7fe6948..b79b3d92154 100644 --- a/compiler/rustc_mir/src/interpret/place.rs +++ b/compiler/rustc_mir/src/interpret/place.rs @@ -33,6 +33,9 @@ pub enum MemPlaceMeta<Tag = ()> { Poison, } +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(MemPlaceMeta, 24); + impl<Tag> MemPlaceMeta<Tag> { pub fn unwrap_meta(self) -> Scalar<Tag> { match self { @@ -71,6 +74,9 @@ pub struct MemPlace<Tag = ()> { pub meta: MemPlaceMeta<Tag>, } +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(MemPlace, 56); + #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable)] pub enum Place<Tag = ()> { /// A place referring to a value allocated in the `Memory` system. @@ -81,12 +87,18 @@ pub enum Place<Tag = ()> { Local { frame: usize, local: mir::Local }, } +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(Place, 64); + #[derive(Copy, Clone, Debug)] pub struct PlaceTy<'tcx, Tag = ()> { place: Place<Tag>, // Keep this private; it helps enforce invariants. pub layout: TyAndLayout<'tcx>, } +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(PlaceTy<'_>, 80); + impl<'tcx, Tag> std::ops::Deref for PlaceTy<'tcx, Tag> { type Target = Place<Tag>; #[inline(always)] @@ -102,6 +114,9 @@ pub struct MPlaceTy<'tcx, Tag = ()> { pub layout: TyAndLayout<'tcx>, } +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(MPlaceTy<'_>, 72); + impl<'tcx, Tag> std::ops::Deref for MPlaceTy<'tcx, Tag> { type Target = MemPlace<Tag>; #[inline(always)] |
