]> git.lizzy.rs Git - rust.git/blob - src/librustc_mir/interpret/place.rs
Suggest `mem::forget` if `mem::ManuallyDrop::new` isn't used
[rust.git] / src / librustc_mir / interpret / place.rs
1 //! Computations on places -- field projections, going from mir::Place, and writing
2 //! into a place.
3 //! All high-level functions to write to memory work on places as destinations.
4
5 use std::convert::TryFrom;
6 use std::hash::Hash;
7
8 use rustc_macros::HashStable;
9 use rustc_middle::mir;
10 use rustc_middle::ty::layout::{PrimitiveExt, TyAndLayout};
11 use rustc_middle::ty::{self, Ty};
12 use rustc_target::abi::{Abi, Align, FieldsShape, TagEncoding};
13 use rustc_target::abi::{HasDataLayout, LayoutOf, Size, VariantIdx, Variants};
14
15 use super::{
16     mir_assign_valid_types, truncate, AllocId, AllocMap, Allocation, AllocationExtra, ImmTy,
17     Immediate, InterpCx, InterpResult, LocalValue, Machine, MemoryKind, OpTy, Operand, Pointer,
18     PointerArithmetic, RawConst, Scalar, ScalarMaybeUninit,
19 };
20
21 #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable)]
22 /// Information required for the sound usage of a `MemPlace`.
23 pub enum MemPlaceMeta<Tag = ()> {
24     /// The unsized payload (e.g. length for slices or vtable pointer for trait objects).
25     Meta(Scalar<Tag>),
26     /// `Sized` types or unsized `extern type`
27     None,
28     /// The address of this place may not be taken. This protects the `MemPlace` from coming from
29     /// a ZST Operand without a backing allocation and being converted to an integer address. This
30     /// should be impossible, because you can't take the address of an operand, but this is a second
31     /// protection layer ensuring that we don't mess up.
32     Poison,
33 }
34
35 impl<Tag> MemPlaceMeta<Tag> {
36     pub fn unwrap_meta(self) -> Scalar<Tag> {
37         match self {
38             Self::Meta(s) => s,
39             Self::None | Self::Poison => {
40                 bug!("expected wide pointer extra data (e.g. slice length or trait object vtable)")
41             }
42         }
43     }
44     fn has_meta(self) -> bool {
45         match self {
46             Self::Meta(_) => true,
47             Self::None | Self::Poison => false,
48         }
49     }
50
51     pub fn erase_tag(self) -> MemPlaceMeta<()> {
52         match self {
53             Self::Meta(s) => MemPlaceMeta::Meta(s.erase_tag()),
54             Self::None => MemPlaceMeta::None,
55             Self::Poison => MemPlaceMeta::Poison,
56         }
57     }
58 }
59
60 #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable)]
61 pub struct MemPlace<Tag = ()> {
62     /// A place may have an integral pointer for ZSTs, and since it might
63     /// be turned back into a reference before ever being dereferenced.
64     /// However, it may never be uninit.
65     pub ptr: Scalar<Tag>,
66     pub align: Align,
67     /// Metadata for unsized places. Interpretation is up to the type.
68     /// Must not be present for sized types, but can be missing for unsized types
69     /// (e.g., `extern type`).
70     pub meta: MemPlaceMeta<Tag>,
71 }
72
73 #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable)]
74 pub enum Place<Tag = ()> {
75     /// A place referring to a value allocated in the `Memory` system.
76     Ptr(MemPlace<Tag>),
77
78     /// To support alloc-free locals, we are able to write directly to a local.
79     /// (Without that optimization, we'd just always be a `MemPlace`.)
80     Local { frame: usize, local: mir::Local },
81 }
82
83 #[derive(Copy, Clone, Debug)]
84 pub struct PlaceTy<'tcx, Tag = ()> {
85     place: Place<Tag>, // Keep this private; it helps enforce invariants.
86     pub layout: TyAndLayout<'tcx>,
87 }
88
89 impl<'tcx, Tag> ::std::ops::Deref for PlaceTy<'tcx, Tag> {
90     type Target = Place<Tag>;
91     #[inline(always)]
92     fn deref(&self) -> &Place<Tag> {
93         &self.place
94     }
95 }
96
97 /// A MemPlace with its layout. Constructing it is only possible in this module.
98 #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
99 pub struct MPlaceTy<'tcx, Tag = ()> {
100     mplace: MemPlace<Tag>,
101     pub layout: TyAndLayout<'tcx>,
102 }
103
104 impl<'tcx, Tag> ::std::ops::Deref for MPlaceTy<'tcx, Tag> {
105     type Target = MemPlace<Tag>;
106     #[inline(always)]
107     fn deref(&self) -> &MemPlace<Tag> {
108         &self.mplace
109     }
110 }
111
112 impl<'tcx, Tag> From<MPlaceTy<'tcx, Tag>> for PlaceTy<'tcx, Tag> {
113     #[inline(always)]
114     fn from(mplace: MPlaceTy<'tcx, Tag>) -> Self {
115         PlaceTy { place: Place::Ptr(mplace.mplace), layout: mplace.layout }
116     }
117 }
118
119 impl<Tag> MemPlace<Tag> {
120     /// Replace ptr tag, maintain vtable tag (if any)
121     #[inline]
122     pub fn replace_tag(self, new_tag: Tag) -> Self {
123         MemPlace { ptr: self.ptr.erase_tag().with_tag(new_tag), align: self.align, meta: self.meta }
124     }
125
126     #[inline]
127     pub fn erase_tag(self) -> MemPlace {
128         MemPlace { ptr: self.ptr.erase_tag(), align: self.align, meta: self.meta.erase_tag() }
129     }
130
131     #[inline(always)]
132     fn from_scalar_ptr(ptr: Scalar<Tag>, align: Align) -> Self {
133         MemPlace { ptr, align, meta: MemPlaceMeta::None }
134     }
135
136     #[inline(always)]
137     pub fn from_ptr(ptr: Pointer<Tag>, align: Align) -> Self {
138         Self::from_scalar_ptr(ptr.into(), align)
139     }
140
141     /// Turn a mplace into a (thin or wide) pointer, as a reference, pointing to the same space.
142     /// This is the inverse of `ref_to_mplace`.
143     #[inline(always)]
144     pub fn to_ref(self) -> Immediate<Tag> {
145         match self.meta {
146             MemPlaceMeta::None => Immediate::Scalar(self.ptr.into()),
147             MemPlaceMeta::Meta(meta) => Immediate::ScalarPair(self.ptr.into(), meta.into()),
148             MemPlaceMeta::Poison => bug!(
149                 "MPlaceTy::dangling may never be used to produce a \
150                 place that will have the address of its pointee taken"
151             ),
152         }
153     }
154
155     pub fn offset(
156         self,
157         offset: Size,
158         meta: MemPlaceMeta<Tag>,
159         cx: &impl HasDataLayout,
160     ) -> InterpResult<'tcx, Self> {
161         Ok(MemPlace {
162             ptr: self.ptr.ptr_offset(offset, cx)?,
163             align: self.align.restrict_for_offset(offset),
164             meta,
165         })
166     }
167 }
168
169 impl<'tcx, Tag> MPlaceTy<'tcx, Tag> {
170     /// Produces a MemPlace that works for ZST but nothing else
171     #[inline]
172     pub fn dangling(layout: TyAndLayout<'tcx>, cx: &impl HasDataLayout) -> Self {
173         let align = layout.align.abi;
174         let ptr = Scalar::from_machine_usize(align.bytes(), cx);
175         // `Poison` this to make sure that the pointer value `ptr` is never observable by the program.
176         MPlaceTy { mplace: MemPlace { ptr, align, meta: MemPlaceMeta::Poison }, layout }
177     }
178
179     /// Replace ptr tag, maintain vtable tag (if any)
180     #[inline]
181     pub fn replace_tag(self, new_tag: Tag) -> Self {
182         MPlaceTy { mplace: self.mplace.replace_tag(new_tag), layout: self.layout }
183     }
184
185     #[inline]
186     pub fn offset(
187         self,
188         offset: Size,
189         meta: MemPlaceMeta<Tag>,
190         layout: TyAndLayout<'tcx>,
191         cx: &impl HasDataLayout,
192     ) -> InterpResult<'tcx, Self> {
193         Ok(MPlaceTy { mplace: self.mplace.offset(offset, meta, cx)?, layout })
194     }
195
196     #[inline]
197     fn from_aligned_ptr(ptr: Pointer<Tag>, layout: TyAndLayout<'tcx>) -> Self {
198         MPlaceTy { mplace: MemPlace::from_ptr(ptr, layout.align.abi), layout }
199     }
200
201     #[inline]
202     pub(super) fn len(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, u64> {
203         if self.layout.is_unsized() {
204             // We need to consult `meta` metadata
205             match self.layout.ty.kind {
206                 ty::Slice(..) | ty::Str => self.mplace.meta.unwrap_meta().to_machine_usize(cx),
207                 _ => bug!("len not supported on unsized type {:?}", self.layout.ty),
208             }
209         } else {
210             // Go through the layout.  There are lots of types that support a length,
211             // e.g., SIMD types.
212             match self.layout.fields {
213                 FieldsShape::Array { count, .. } => Ok(count),
214                 _ => bug!("len not supported on sized type {:?}", self.layout.ty),
215             }
216         }
217     }
218
219     #[inline]
220     pub(super) fn vtable(self) -> Scalar<Tag> {
221         match self.layout.ty.kind {
222             ty::Dynamic(..) => self.mplace.meta.unwrap_meta(),
223             _ => bug!("vtable not supported on type {:?}", self.layout.ty),
224         }
225     }
226 }
227
228 // These are defined here because they produce a place.
229 impl<'tcx, Tag: ::std::fmt::Debug + Copy> OpTy<'tcx, Tag> {
230     #[inline(always)]
231     /// Note: do not call `as_ref` on the resulting place. This function should only be used to
232     /// read from the resulting mplace, not to get its address back.
233     pub fn try_as_mplace(
234         self,
235         cx: &impl HasDataLayout,
236     ) -> Result<MPlaceTy<'tcx, Tag>, ImmTy<'tcx, Tag>> {
237         match *self {
238             Operand::Indirect(mplace) => Ok(MPlaceTy { mplace, layout: self.layout }),
239             Operand::Immediate(_) if self.layout.is_zst() => {
240                 Ok(MPlaceTy::dangling(self.layout, cx))
241             }
242             Operand::Immediate(imm) => Err(ImmTy::from_immediate(imm, self.layout)),
243         }
244     }
245
246     #[inline(always)]
247     /// Note: do not call `as_ref` on the resulting place. This function should only be used to
248     /// read from the resulting mplace, not to get its address back.
249     pub fn assert_mem_place(self, cx: &impl HasDataLayout) -> MPlaceTy<'tcx, Tag> {
250         self.try_as_mplace(cx).unwrap()
251     }
252 }
253
254 impl<Tag: ::std::fmt::Debug> Place<Tag> {
255     #[inline]
256     pub fn assert_mem_place(self) -> MemPlace<Tag> {
257         match self {
258             Place::Ptr(mplace) => mplace,
259             _ => bug!("assert_mem_place: expected Place::Ptr, got {:?}", self),
260         }
261     }
262 }
263
264 impl<'tcx, Tag: ::std::fmt::Debug> PlaceTy<'tcx, Tag> {
265     #[inline]
266     pub fn assert_mem_place(self) -> MPlaceTy<'tcx, Tag> {
267         MPlaceTy { mplace: self.place.assert_mem_place(), layout: self.layout }
268     }
269 }
270
271 // separating the pointer tag for `impl Trait`, see https://github.com/rust-lang/rust/issues/54385
272 impl<'mir, 'tcx: 'mir, Tag, M> InterpCx<'mir, 'tcx, M>
273 where
274     // FIXME: Working around https://github.com/rust-lang/rust/issues/54385
275     Tag: ::std::fmt::Debug + Copy + Eq + Hash + 'static,
276     M: Machine<'mir, 'tcx, PointerTag = Tag>,
277     // FIXME: Working around https://github.com/rust-lang/rust/issues/24159
278     M::MemoryMap: AllocMap<AllocId, (MemoryKind<M::MemoryKind>, Allocation<Tag, M::AllocExtra>)>,
279     M::AllocExtra: AllocationExtra<Tag>,
280 {
281     /// Take a value, which represents a (thin or wide) reference, and make it a place.
282     /// Alignment is just based on the type.  This is the inverse of `MemPlace::to_ref()`.
283     ///
284     /// Only call this if you are sure the place is "valid" (aligned and inbounds), or do not
285     /// want to ever use the place for memory access!
286     /// Generally prefer `deref_operand`.
287     pub fn ref_to_mplace(
288         &self,
289         val: ImmTy<'tcx, M::PointerTag>,
290     ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
291         let pointee_type =
292             val.layout.ty.builtin_deref(true).expect("`ref_to_mplace` called on non-ptr type").ty;
293         let layout = self.layout_of(pointee_type)?;
294         let (ptr, meta) = match *val {
295             Immediate::Scalar(ptr) => (ptr.check_init()?, MemPlaceMeta::None),
296             Immediate::ScalarPair(ptr, meta) => {
297                 (ptr.check_init()?, MemPlaceMeta::Meta(meta.check_init()?))
298             }
299         };
300
301         let mplace = MemPlace {
302             ptr,
303             // We could use the run-time alignment here. For now, we do not, because
304             // the point of tracking the alignment here is to make sure that the *static*
305             // alignment information emitted with the loads is correct. The run-time
306             // alignment can only be more restrictive.
307             align: layout.align.abi,
308             meta,
309         };
310         Ok(MPlaceTy { mplace, layout })
311     }
312
313     /// Take an operand, representing a pointer, and dereference it to a place -- that
314     /// will always be a MemPlace.  Lives in `place.rs` because it creates a place.
315     pub fn deref_operand(
316         &self,
317         src: OpTy<'tcx, M::PointerTag>,
318     ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
319         let val = self.read_immediate(src)?;
320         trace!("deref to {} on {:?}", val.layout.ty, *val);
321         let place = self.ref_to_mplace(val)?;
322         self.mplace_access_checked(place, None)
323     }
324
325     /// Check if the given place is good for memory access with the given
326     /// size, falling back to the layout's size if `None` (in the latter case,
327     /// this must be a statically sized type).
328     ///
329     /// On success, returns `None` for zero-sized accesses (where nothing else is
330     /// left to do) and a `Pointer` to use for the actual access otherwise.
331     #[inline]
332     pub(super) fn check_mplace_access(
333         &self,
334         place: MPlaceTy<'tcx, M::PointerTag>,
335         size: Option<Size>,
336     ) -> InterpResult<'tcx, Option<Pointer<M::PointerTag>>> {
337         let size = size.unwrap_or_else(|| {
338             assert!(!place.layout.is_unsized());
339             assert!(!place.meta.has_meta());
340             place.layout.size
341         });
342         self.memory.check_ptr_access(place.ptr, size, place.align)
343     }
344
345     /// Return the "access-checked" version of this `MPlace`, where for non-ZST
346     /// this is definitely a `Pointer`.
347     ///
348     /// `force_align` must only be used when correct alignment does not matter,
349     /// like in Stacked Borrows.
350     pub fn mplace_access_checked(
351         &self,
352         mut place: MPlaceTy<'tcx, M::PointerTag>,
353         force_align: Option<Align>,
354     ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
355         let (size, align) = self
356             .size_and_align_of_mplace(place)?
357             .unwrap_or((place.layout.size, place.layout.align.abi));
358         assert!(place.mplace.align <= align, "dynamic alignment less strict than static one?");
359         // Check (stricter) dynamic alignment, unless forced otherwise.
360         place.mplace.align = force_align.unwrap_or(align);
361         // When dereferencing a pointer, it must be non-NULL, aligned, and live.
362         if let Some(ptr) = self.check_mplace_access(place, Some(size))? {
363             place.mplace.ptr = ptr.into();
364         }
365         Ok(place)
366     }
367
368     /// Force `place.ptr` to a `Pointer`.
369     /// Can be helpful to avoid lots of `force_ptr` calls later, if this place is used a lot.
370     pub(super) fn force_mplace_ptr(
371         &self,
372         mut place: MPlaceTy<'tcx, M::PointerTag>,
373     ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
374         place.mplace.ptr = self.force_ptr(place.mplace.ptr)?.into();
375         Ok(place)
376     }
377
378     /// Offset a pointer to project to a field of a struct/union. Unlike `place_field`, this is
379     /// always possible without allocating, so it can take `&self`. Also return the field's layout.
380     /// This supports both struct and array fields.
381     ///
382     /// This also works for arrays, but then the `usize` index type is restricting.
383     /// For indexing into arrays, use `mplace_index`.
384     #[inline(always)]
385     pub fn mplace_field(
386         &self,
387         base: MPlaceTy<'tcx, M::PointerTag>,
388         field: usize,
389     ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
390         let offset = base.layout.fields.offset(field);
391         let field_layout = base.layout.field(self, field)?;
392
393         // Offset may need adjustment for unsized fields.
394         let (meta, offset) = if field_layout.is_unsized() {
395             // Re-use parent metadata to determine dynamic field layout.
396             // With custom DSTS, this *will* execute user-defined code, but the same
397             // happens at run-time so that's okay.
398             let align = match self.size_and_align_of(base.meta, field_layout)? {
399                 Some((_, align)) => align,
400                 None if offset == Size::ZERO => {
401                     // An extern type at offset 0, we fall back to its static alignment.
402                     // FIXME: Once we have made decisions for how to handle size and alignment
403                     // of `extern type`, this should be adapted.  It is just a temporary hack
404                     // to get some code to work that probably ought to work.
405                     field_layout.align.abi
406                 }
407                 None => span_bug!(
408                     self.cur_span(),
409                     "cannot compute offset for extern type field at non-0 offset"
410                 ),
411             };
412             (base.meta, offset.align_to(align))
413         } else {
414             // base.meta could be present; we might be accessing a sized field of an unsized
415             // struct.
416             (MemPlaceMeta::None, offset)
417         };
418
419         // We do not look at `base.layout.align` nor `field_layout.align`, unlike
420         // codegen -- mostly to see if we can get away with that
421         base.offset(offset, meta, field_layout, self)
422     }
423
424     /// Index into an array.
425     #[inline(always)]
426     pub fn mplace_index(
427         &self,
428         base: MPlaceTy<'tcx, M::PointerTag>,
429         index: u64,
430     ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
431         // Not using the layout method because we want to compute on u64
432         match base.layout.fields {
433             FieldsShape::Array { stride, .. } => {
434                 let len = base.len(self)?;
435                 if index >= len {
436                     // This can only be reached in ConstProp and non-rustc-MIR.
437                     throw_ub!(BoundsCheckFailed { len, index });
438                 }
439                 let offset = stride * index; // `Size` multiplication
440                 // All fields have the same layout.
441                 let field_layout = base.layout.field(self, 0)?;
442
443                 assert!(!field_layout.is_unsized());
444                 base.offset(offset, MemPlaceMeta::None, field_layout, self)
445             }
446             _ => span_bug!(
447                 self.cur_span(),
448                 "`mplace_index` called on non-array type {:?}",
449                 base.layout.ty
450             ),
451         }
452     }
453
454     // Iterates over all fields of an array. Much more efficient than doing the
455     // same by repeatedly calling `mplace_array`.
456     pub(super) fn mplace_array_fields(
457         &self,
458         base: MPlaceTy<'tcx, Tag>,
459     ) -> InterpResult<'tcx, impl Iterator<Item = InterpResult<'tcx, MPlaceTy<'tcx, Tag>>> + 'tcx>
460     {
461         let len = base.len(self)?; // also asserts that we have a type where this makes sense
462         let stride = match base.layout.fields {
463             FieldsShape::Array { stride, .. } => stride,
464             _ => span_bug!(self.cur_span(), "mplace_array_fields: expected an array layout"),
465         };
466         let layout = base.layout.field(self, 0)?;
467         let dl = &self.tcx.data_layout;
468         // `Size` multiplication
469         Ok((0..len).map(move |i| base.offset(stride * i, MemPlaceMeta::None, layout, dl)))
470     }
471
472     fn mplace_subslice(
473         &self,
474         base: MPlaceTy<'tcx, M::PointerTag>,
475         from: u64,
476         to: u64,
477         from_end: bool,
478     ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
479         let len = base.len(self)?; // also asserts that we have a type where this makes sense
480         let actual_to = if from_end {
481             if from.checked_add(to).map_or(true, |to| to > len) {
482                 // This can only be reached in ConstProp and non-rustc-MIR.
483                 throw_ub!(BoundsCheckFailed { len: len, index: from.saturating_add(to) });
484             }
485             len.checked_sub(to).unwrap()
486         } else {
487             to
488         };
489
490         // Not using layout method because that works with usize, and does not work with slices
491         // (that have count 0 in their layout).
492         let from_offset = match base.layout.fields {
493             FieldsShape::Array { stride, .. } => stride * from, // `Size` multiplication is checked
494             _ => {
495                 span_bug!(self.cur_span(), "unexpected layout of index access: {:#?}", base.layout)
496             }
497         };
498
499         // Compute meta and new layout
500         let inner_len = actual_to.checked_sub(from).unwrap();
501         let (meta, ty) = match base.layout.ty.kind {
502             // It is not nice to match on the type, but that seems to be the only way to
503             // implement this.
504             ty::Array(inner, _) => (MemPlaceMeta::None, self.tcx.mk_array(inner, inner_len)),
505             ty::Slice(..) => {
506                 let len = Scalar::from_machine_usize(inner_len, self);
507                 (MemPlaceMeta::Meta(len), base.layout.ty)
508             }
509             _ => {
510                 span_bug!(self.cur_span(), "cannot subslice non-array type: `{:?}`", base.layout.ty)
511             }
512         };
513         let layout = self.layout_of(ty)?;
514         base.offset(from_offset, meta, layout, self)
515     }
516
517     pub(super) fn mplace_downcast(
518         &self,
519         base: MPlaceTy<'tcx, M::PointerTag>,
520         variant: VariantIdx,
521     ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
522         // Downcasts only change the layout
523         assert!(!base.meta.has_meta());
524         Ok(MPlaceTy { layout: base.layout.for_variant(self, variant), ..base })
525     }
526
527     /// Project into an mplace
528     pub(super) fn mplace_projection(
529         &self,
530         base: MPlaceTy<'tcx, M::PointerTag>,
531         proj_elem: mir::PlaceElem<'tcx>,
532     ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
533         use rustc_middle::mir::ProjectionElem::*;
534         Ok(match proj_elem {
535             Field(field, _) => self.mplace_field(base, field.index())?,
536             Downcast(_, variant) => self.mplace_downcast(base, variant)?,
537             Deref => self.deref_operand(base.into())?,
538
539             Index(local) => {
540                 let layout = self.layout_of(self.tcx.types.usize)?;
541                 let n = self.access_local(self.frame(), local, Some(layout))?;
542                 let n = self.read_scalar(n)?;
543                 let n = u64::try_from(
544                     self.force_bits(n.check_init()?, self.tcx.data_layout.pointer_size)?,
545                 )
546                 .unwrap();
547                 self.mplace_index(base, n)?
548             }
549
550             ConstantIndex { offset, min_length, from_end } => {
551                 let n = base.len(self)?;
552                 if n < u64::from(min_length) {
553                     // This can only be reached in ConstProp and non-rustc-MIR.
554                     throw_ub!(BoundsCheckFailed { len: min_length.into(), index: n });
555                 }
556
557                 let index = if from_end {
558                     assert!(0 < offset && offset <= min_length);
559                     n.checked_sub(u64::from(offset)).unwrap()
560                 } else {
561                     assert!(offset < min_length);
562                     u64::from(offset)
563                 };
564
565                 self.mplace_index(base, index)?
566             }
567
568             Subslice { from, to, from_end } => {
569                 self.mplace_subslice(base, u64::from(from), u64::from(to), from_end)?
570             }
571         })
572     }
573
574     /// Gets the place of a field inside the place, and also the field's type.
575     /// Just a convenience function, but used quite a bit.
576     /// This is the only projection that might have a side-effect: We cannot project
577     /// into the field of a local `ScalarPair`, we have to first allocate it.
578     pub fn place_field(
579         &mut self,
580         base: PlaceTy<'tcx, M::PointerTag>,
581         field: usize,
582     ) -> InterpResult<'tcx, PlaceTy<'tcx, M::PointerTag>> {
583         // FIXME: We could try to be smarter and avoid allocation for fields that span the
584         // entire place.
585         let mplace = self.force_allocation(base)?;
586         Ok(self.mplace_field(mplace, field)?.into())
587     }
588
589     pub fn place_index(
590         &mut self,
591         base: PlaceTy<'tcx, M::PointerTag>,
592         index: u64,
593     ) -> InterpResult<'tcx, PlaceTy<'tcx, M::PointerTag>> {
594         let mplace = self.force_allocation(base)?;
595         Ok(self.mplace_index(mplace, index)?.into())
596     }
597
598     pub fn place_downcast(
599         &self,
600         base: PlaceTy<'tcx, M::PointerTag>,
601         variant: VariantIdx,
602     ) -> InterpResult<'tcx, PlaceTy<'tcx, M::PointerTag>> {
603         // Downcast just changes the layout
604         Ok(match base.place {
605             Place::Ptr(mplace) => {
606                 self.mplace_downcast(MPlaceTy { mplace, layout: base.layout }, variant)?.into()
607             }
608             Place::Local { .. } => {
609                 let layout = base.layout.for_variant(self, variant);
610                 PlaceTy { layout, ..base }
611             }
612         })
613     }
614
615     /// Projects into a place.
616     pub fn place_projection(
617         &mut self,
618         base: PlaceTy<'tcx, M::PointerTag>,
619         &proj_elem: &mir::ProjectionElem<mir::Local, Ty<'tcx>>,
620     ) -> InterpResult<'tcx, PlaceTy<'tcx, M::PointerTag>> {
621         use rustc_middle::mir::ProjectionElem::*;
622         Ok(match proj_elem {
623             Field(field, _) => self.place_field(base, field.index())?,
624             Downcast(_, variant) => self.place_downcast(base, variant)?,
625             Deref => self.deref_operand(self.place_to_op(base)?)?.into(),
626             // For the other variants, we have to force an allocation.
627             // This matches `operand_projection`.
628             Subslice { .. } | ConstantIndex { .. } | Index(_) => {
629                 let mplace = self.force_allocation(base)?;
630                 self.mplace_projection(mplace, proj_elem)?.into()
631             }
632         })
633     }
634
635     /// Computes a place. You should only use this if you intend to write into this
636     /// place; for reading, a more efficient alternative is `eval_place_for_read`.
637     pub fn eval_place(
638         &mut self,
639         place: mir::Place<'tcx>,
640     ) -> InterpResult<'tcx, PlaceTy<'tcx, M::PointerTag>> {
641         let mut place_ty = PlaceTy {
642             // This works even for dead/uninitialized locals; we check further when writing
643             place: Place::Local { frame: self.frame_idx(), local: place.local },
644             layout: self.layout_of_local(self.frame(), place.local, None)?,
645         };
646
647         for elem in place.projection.iter() {
648             place_ty = self.place_projection(place_ty, &elem)?
649         }
650
651         trace!("{:?}", self.dump_place(place_ty.place));
652         // Sanity-check the type we ended up with.
653         debug_assert!(mir_assign_valid_types(
654             *self.tcx,
655             self.param_env,
656             self.layout_of(self.subst_from_current_frame_and_normalize_erasing_regions(
657                 place.ty(&self.frame().body.local_decls, *self.tcx).ty
658             ))?,
659             place_ty.layout,
660         ));
661         Ok(place_ty)
662     }
663
664     /// Write a scalar to a place
665     #[inline(always)]
666     pub fn write_scalar(
667         &mut self,
668         val: impl Into<ScalarMaybeUninit<M::PointerTag>>,
669         dest: PlaceTy<'tcx, M::PointerTag>,
670     ) -> InterpResult<'tcx> {
671         self.write_immediate(Immediate::Scalar(val.into()), dest)
672     }
673
674     /// Write an immediate to a place
675     #[inline(always)]
676     pub fn write_immediate(
677         &mut self,
678         src: Immediate<M::PointerTag>,
679         dest: PlaceTy<'tcx, M::PointerTag>,
680     ) -> InterpResult<'tcx> {
681         self.write_immediate_no_validate(src, dest)?;
682
683         if M::enforce_validity(self) {
684             // Data got changed, better make sure it matches the type!
685             self.validate_operand(self.place_to_op(dest)?)?;
686         }
687
688         Ok(())
689     }
690
691     /// Write an `Immediate` to memory.
692     #[inline(always)]
693     pub fn write_immediate_to_mplace(
694         &mut self,
695         src: Immediate<M::PointerTag>,
696         dest: MPlaceTy<'tcx, M::PointerTag>,
697     ) -> InterpResult<'tcx> {
698         self.write_immediate_to_mplace_no_validate(src, dest)?;
699
700         if M::enforce_validity(self) {
701             // Data got changed, better make sure it matches the type!
702             self.validate_operand(dest.into())?;
703         }
704
705         Ok(())
706     }
707
708     /// Write an immediate to a place.
709     /// If you use this you are responsible for validating that things got copied at the
710     /// right type.
711     fn write_immediate_no_validate(
712         &mut self,
713         src: Immediate<M::PointerTag>,
714         dest: PlaceTy<'tcx, M::PointerTag>,
715     ) -> InterpResult<'tcx> {
716         if cfg!(debug_assertions) {
717             // This is a very common path, avoid some checks in release mode
718             assert!(!dest.layout.is_unsized(), "Cannot write unsized data");
719             match src {
720                 Immediate::Scalar(ScalarMaybeUninit::Scalar(Scalar::Ptr(_))) => assert_eq!(
721                     self.pointer_size(),
722                     dest.layout.size,
723                     "Size mismatch when writing pointer"
724                 ),
725                 Immediate::Scalar(ScalarMaybeUninit::Scalar(Scalar::Raw { size, .. })) => {
726                     assert_eq!(
727                         Size::from_bytes(size),
728                         dest.layout.size,
729                         "Size mismatch when writing bits"
730                     )
731                 }
732                 Immediate::Scalar(ScalarMaybeUninit::Uninit) => {} // uninit can have any size
733                 Immediate::ScalarPair(_, _) => {
734                     // FIXME: Can we check anything here?
735                 }
736             }
737         }
738         trace!("write_immediate: {:?} <- {:?}: {}", *dest, src, dest.layout.ty);
739
740         // See if we can avoid an allocation. This is the counterpart to `try_read_immediate`,
741         // but not factored as a separate function.
742         let mplace = match dest.place {
743             Place::Local { frame, local } => {
744                 match M::access_local_mut(self, frame, local)? {
745                     Ok(local) => {
746                         // Local can be updated in-place.
747                         *local = LocalValue::Live(Operand::Immediate(src));
748                         return Ok(());
749                     }
750                     Err(mplace) => {
751                         // The local is in memory, go on below.
752                         mplace
753                     }
754                 }
755             }
756             Place::Ptr(mplace) => mplace, // already referring to memory
757         };
758         let dest = MPlaceTy { mplace, layout: dest.layout };
759
760         // This is already in memory, write there.
761         self.write_immediate_to_mplace_no_validate(src, dest)
762     }
763
764     /// Write an immediate to memory.
765     /// If you use this you are responsible for validating that things got copied at the
766     /// right type.
767     fn write_immediate_to_mplace_no_validate(
768         &mut self,
769         value: Immediate<M::PointerTag>,
770         dest: MPlaceTy<'tcx, M::PointerTag>,
771     ) -> InterpResult<'tcx> {
772         // Note that it is really important that the type here is the right one, and matches the
773         // type things are read at. In case `src_val` is a `ScalarPair`, we don't do any magic here
774         // to handle padding properly, which is only correct if we never look at this data with the
775         // wrong type.
776
777         // Invalid places are a thing: the return place of a diverging function
778         let ptr = match self.check_mplace_access(dest, None)? {
779             Some(ptr) => ptr,
780             None => return Ok(()), // zero-sized access
781         };
782
783         let tcx = *self.tcx;
784         // FIXME: We should check that there are dest.layout.size many bytes available in
785         // memory.  The code below is not sufficient, with enough padding it might not
786         // cover all the bytes!
787         match value {
788             Immediate::Scalar(scalar) => {
789                 match dest.layout.abi {
790                     Abi::Scalar(_) => {} // fine
791                     _ => span_bug!(
792                         self.cur_span(),
793                         "write_immediate_to_mplace: invalid Scalar layout: {:#?}",
794                         dest.layout
795                     ),
796                 }
797                 self.memory.get_raw_mut(ptr.alloc_id)?.write_scalar(
798                     &tcx,
799                     ptr,
800                     scalar,
801                     dest.layout.size,
802                 )
803             }
804             Immediate::ScalarPair(a_val, b_val) => {
805                 // We checked `ptr_align` above, so all fields will have the alignment they need.
806                 // We would anyway check against `ptr_align.restrict_for_offset(b_offset)`,
807                 // which `ptr.offset(b_offset)` cannot possibly fail to satisfy.
808                 let (a, b) = match dest.layout.abi {
809                     Abi::ScalarPair(ref a, ref b) => (&a.value, &b.value),
810                     _ => span_bug!(
811                         self.cur_span(),
812                         "write_immediate_to_mplace: invalid ScalarPair layout: {:#?}",
813                         dest.layout
814                     ),
815                 };
816                 let (a_size, b_size) = (a.size(self), b.size(self));
817                 let b_offset = a_size.align_to(b.align(self).abi);
818                 let b_ptr = ptr.offset(b_offset, self)?;
819
820                 // It is tempting to verify `b_offset` against `layout.fields.offset(1)`,
821                 // but that does not work: We could be a newtype around a pair, then the
822                 // fields do not match the `ScalarPair` components.
823
824                 self.memory.get_raw_mut(ptr.alloc_id)?.write_scalar(&tcx, ptr, a_val, a_size)?;
825                 self.memory.get_raw_mut(b_ptr.alloc_id)?.write_scalar(&tcx, b_ptr, b_val, b_size)
826             }
827         }
828     }
829
830     /// Copies the data from an operand to a place. This does not support transmuting!
831     /// Use `copy_op_transmute` if the layouts could disagree.
832     #[inline(always)]
833     pub fn copy_op(
834         &mut self,
835         src: OpTy<'tcx, M::PointerTag>,
836         dest: PlaceTy<'tcx, M::PointerTag>,
837     ) -> InterpResult<'tcx> {
838         self.copy_op_no_validate(src, dest)?;
839
840         if M::enforce_validity(self) {
841             // Data got changed, better make sure it matches the type!
842             self.validate_operand(self.place_to_op(dest)?)?;
843         }
844
845         Ok(())
846     }
847
848     /// Copies the data from an operand to a place. This does not support transmuting!
849     /// Use `copy_op_transmute` if the layouts could disagree.
850     /// Also, if you use this you are responsible for validating that things get copied at the
851     /// right type.
852     fn copy_op_no_validate(
853         &mut self,
854         src: OpTy<'tcx, M::PointerTag>,
855         dest: PlaceTy<'tcx, M::PointerTag>,
856     ) -> InterpResult<'tcx> {
857         // We do NOT compare the types for equality, because well-typed code can
858         // actually "transmute" `&mut T` to `&T` in an assignment without a cast.
859         if !mir_assign_valid_types(*self.tcx, self.param_env, src.layout, dest.layout) {
860             span_bug!(
861                 self.cur_span(),
862                 "type mismatch when copying!\nsrc: {:?},\ndest: {:?}",
863                 src.layout.ty,
864                 dest.layout.ty,
865             );
866         }
867
868         // Let us see if the layout is simple so we take a shortcut, avoid force_allocation.
869         let src = match self.try_read_immediate(src)? {
870             Ok(src_val) => {
871                 assert!(!src.layout.is_unsized(), "cannot have unsized immediates");
872                 // Yay, we got a value that we can write directly.
873                 // FIXME: Add a check to make sure that if `src` is indirect,
874                 // it does not overlap with `dest`.
875                 return self.write_immediate_no_validate(*src_val, dest);
876             }
877             Err(mplace) => mplace,
878         };
879         // Slow path, this does not fit into an immediate. Just memcpy.
880         trace!("copy_op: {:?} <- {:?}: {}", *dest, src, dest.layout.ty);
881
882         // This interprets `src.meta` with the `dest` local's layout, if an unsized local
883         // is being initialized!
884         let (dest, size) = self.force_allocation_maybe_sized(dest, src.meta)?;
885         let size = size.unwrap_or_else(|| {
886             assert!(
887                 !dest.layout.is_unsized(),
888                 "Cannot copy into already initialized unsized place"
889             );
890             dest.layout.size
891         });
892         assert_eq!(src.meta, dest.meta, "Can only copy between equally-sized instances");
893
894         let src = self
895             .check_mplace_access(src, Some(size))
896             .expect("places should be checked on creation");
897         let dest = self
898             .check_mplace_access(dest, Some(size))
899             .expect("places should be checked on creation");
900         let (src_ptr, dest_ptr) = match (src, dest) {
901             (Some(src_ptr), Some(dest_ptr)) => (src_ptr, dest_ptr),
902             (None, None) => return Ok(()), // zero-sized copy
903             _ => bug!("The pointers should both be Some or both None"),
904         };
905
906         self.memory.copy(src_ptr, dest_ptr, size, /*nonoverlapping*/ true)
907     }
908
909     /// Copies the data from an operand to a place. The layouts may disagree, but they must
910     /// have the same size.
911     pub fn copy_op_transmute(
912         &mut self,
913         src: OpTy<'tcx, M::PointerTag>,
914         dest: PlaceTy<'tcx, M::PointerTag>,
915     ) -> InterpResult<'tcx> {
916         if mir_assign_valid_types(*self.tcx, self.param_env, src.layout, dest.layout) {
917             // Fast path: Just use normal `copy_op`
918             return self.copy_op(src, dest);
919         }
920         // We still require the sizes to match.
921         if src.layout.size != dest.layout.size {
922             // FIXME: This should be an assert instead of an error, but if we transmute within an
923             // array length computation, `typeck` may not have yet been run and errored out. In fact
924             // most likey we *are* running `typeck` right now. Investigate whether we can bail out
925             // on `typeck_results().has_errors` at all const eval entry points.
926             debug!("Size mismatch when transmuting!\nsrc: {:#?}\ndest: {:#?}", src, dest);
927             self.tcx.sess.delay_span_bug(
928                 self.cur_span(),
929                 "size-changing transmute, should have been caught by transmute checking",
930             );
931             throw_inval!(TransmuteSizeDiff(src.layout.ty, dest.layout.ty));
932         }
933         // Unsized copies rely on interpreting `src.meta` with `dest.layout`, we want
934         // to avoid that here.
935         assert!(
936             !src.layout.is_unsized() && !dest.layout.is_unsized(),
937             "Cannot transmute unsized data"
938         );
939
940         // The hard case is `ScalarPair`.  `src` is already read from memory in this case,
941         // using `src.layout` to figure out which bytes to use for the 1st and 2nd field.
942         // We have to write them to `dest` at the offsets they were *read at*, which is
943         // not necessarily the same as the offsets in `dest.layout`!
944         // Hence we do the copy with the source layout on both sides.  We also make sure to write
945         // into memory, because if `dest` is a local we would not even have a way to write
946         // at the `src` offsets; the fact that we came from a different layout would
947         // just be lost.
948         let dest = self.force_allocation(dest)?;
949         self.copy_op_no_validate(
950             src,
951             PlaceTy::from(MPlaceTy { mplace: *dest, layout: src.layout }),
952         )?;
953
954         if M::enforce_validity(self) {
955             // Data got changed, better make sure it matches the type!
956             self.validate_operand(dest.into())?;
957         }
958
959         Ok(())
960     }
961
962     /// Ensures that a place is in memory, and returns where it is.
963     /// If the place currently refers to a local that doesn't yet have a matching allocation,
964     /// create such an allocation.
965     /// This is essentially `force_to_memplace`.
966     ///
967     /// This supports unsized types and returns the computed size to avoid some
968     /// redundant computation when copying; use `force_allocation` for a simpler, sized-only
969     /// version.
970     pub fn force_allocation_maybe_sized(
971         &mut self,
972         place: PlaceTy<'tcx, M::PointerTag>,
973         meta: MemPlaceMeta<M::PointerTag>,
974     ) -> InterpResult<'tcx, (MPlaceTy<'tcx, M::PointerTag>, Option<Size>)> {
975         let (mplace, size) = match place.place {
976             Place::Local { frame, local } => {
977                 match M::access_local_mut(self, frame, local)? {
978                     Ok(&mut local_val) => {
979                         // We need to make an allocation.
980
981                         // We need the layout of the local.  We can NOT use the layout we got,
982                         // that might e.g., be an inner field of a struct with `Scalar` layout,
983                         // that has different alignment than the outer field.
984                         let local_layout =
985                             self.layout_of_local(&self.stack()[frame], local, None)?;
986                         // We also need to support unsized types, and hence cannot use `allocate`.
987                         let (size, align) = self
988                             .size_and_align_of(meta, local_layout)?
989                             .expect("Cannot allocate for non-dyn-sized type");
990                         let ptr = self.memory.allocate(size, align, MemoryKind::Stack);
991                         let mplace = MemPlace { ptr: ptr.into(), align, meta };
992                         if let LocalValue::Live(Operand::Immediate(value)) = local_val {
993                             // Preserve old value.
994                             // We don't have to validate as we can assume the local
995                             // was already valid for its type.
996                             let mplace = MPlaceTy { mplace, layout: local_layout };
997                             self.write_immediate_to_mplace_no_validate(value, mplace)?;
998                         }
999                         // Now we can call `access_mut` again, asserting it goes well,
1000                         // and actually overwrite things.
1001                         *M::access_local_mut(self, frame, local).unwrap().unwrap() =
1002                             LocalValue::Live(Operand::Indirect(mplace));
1003                         (mplace, Some(size))
1004                     }
1005                     Err(mplace) => (mplace, None), // this already was an indirect local
1006                 }
1007             }
1008             Place::Ptr(mplace) => (mplace, None),
1009         };
1010         // Return with the original layout, so that the caller can go on
1011         Ok((MPlaceTy { mplace, layout: place.layout }, size))
1012     }
1013
1014     #[inline(always)]
1015     pub fn force_allocation(
1016         &mut self,
1017         place: PlaceTy<'tcx, M::PointerTag>,
1018     ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
1019         Ok(self.force_allocation_maybe_sized(place, MemPlaceMeta::None)?.0)
1020     }
1021
1022     pub fn allocate(
1023         &mut self,
1024         layout: TyAndLayout<'tcx>,
1025         kind: MemoryKind<M::MemoryKind>,
1026     ) -> MPlaceTy<'tcx, M::PointerTag> {
1027         let ptr = self.memory.allocate(layout.size, layout.align.abi, kind);
1028         MPlaceTy::from_aligned_ptr(ptr, layout)
1029     }
1030
1031     /// Returns a wide MPlace.
1032     pub fn allocate_str(
1033         &mut self,
1034         str: &str,
1035         kind: MemoryKind<M::MemoryKind>,
1036     ) -> MPlaceTy<'tcx, M::PointerTag> {
1037         let ptr = self.memory.allocate_bytes(str.as_bytes(), kind);
1038         let meta = Scalar::from_machine_usize(u64::try_from(str.len()).unwrap(), self);
1039         let mplace = MemPlace {
1040             ptr: ptr.into(),
1041             align: Align::from_bytes(1).unwrap(),
1042             meta: MemPlaceMeta::Meta(meta),
1043         };
1044
1045         let layout = self.layout_of(self.tcx.mk_static_str()).unwrap();
1046         MPlaceTy { mplace, layout }
1047     }
1048
1049     /// Writes the discriminant of the given variant.
1050     pub fn write_discriminant(
1051         &mut self,
1052         variant_index: VariantIdx,
1053         dest: PlaceTy<'tcx, M::PointerTag>,
1054     ) -> InterpResult<'tcx> {
1055         // Layout computation excludes uninhabited variants from consideration
1056         // therefore there's no way to represent those variants in the given layout.
1057         if dest.layout.for_variant(self, variant_index).abi.is_uninhabited() {
1058             throw_ub!(Unreachable);
1059         }
1060
1061         match dest.layout.variants {
1062             Variants::Single { index } => {
1063                 assert_eq!(index, variant_index);
1064             }
1065             Variants::Multiple {
1066                 tag_encoding: TagEncoding::Direct,
1067                 tag: ref tag_layout,
1068                 tag_field,
1069                 ..
1070             } => {
1071                 // No need to validate that the discriminant here because the
1072                 // `TyAndLayout::for_variant()` call earlier already checks the variant is valid.
1073
1074                 let discr_val =
1075                     dest.layout.ty.discriminant_for_variant(*self.tcx, variant_index).unwrap().val;
1076
1077                 // raw discriminants for enums are isize or bigger during
1078                 // their computation, but the in-memory tag is the smallest possible
1079                 // representation
1080                 let size = tag_layout.value.size(self);
1081                 let tag_val = truncate(discr_val, size);
1082
1083                 let tag_dest = self.place_field(dest, tag_field)?;
1084                 self.write_scalar(Scalar::from_uint(tag_val, size), tag_dest)?;
1085             }
1086             Variants::Multiple {
1087                 tag_encoding:
1088                     TagEncoding::Niche { dataful_variant, ref niche_variants, niche_start },
1089                 tag: ref tag_layout,
1090                 tag_field,
1091                 ..
1092             } => {
1093                 // No need to validate that the discriminant here because the
1094                 // `TyAndLayout::for_variant()` call earlier already checks the variant is valid.
1095
1096                 if variant_index != dataful_variant {
1097                     let variants_start = niche_variants.start().as_u32();
1098                     let variant_index_relative = variant_index
1099                         .as_u32()
1100                         .checked_sub(variants_start)
1101                         .expect("overflow computing relative variant idx");
1102                     // We need to use machine arithmetic when taking into account `niche_start`:
1103                     // tag_val = variant_index_relative + niche_start_val
1104                     let tag_layout = self.layout_of(tag_layout.value.to_int_ty(*self.tcx))?;
1105                     let niche_start_val = ImmTy::from_uint(niche_start, tag_layout);
1106                     let variant_index_relative_val =
1107                         ImmTy::from_uint(variant_index_relative, tag_layout);
1108                     let tag_val = self.binary_op(
1109                         mir::BinOp::Add,
1110                         variant_index_relative_val,
1111                         niche_start_val,
1112                     )?;
1113                     // Write result.
1114                     let niche_dest = self.place_field(dest, tag_field)?;
1115                     self.write_immediate(*tag_val, niche_dest)?;
1116                 }
1117             }
1118         }
1119
1120         Ok(())
1121     }
1122
1123     pub fn raw_const_to_mplace(
1124         &self,
1125         raw: RawConst<'tcx>,
1126     ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
1127         // This must be an allocation in `tcx`
1128         let _ = self.tcx.global_alloc(raw.alloc_id);
1129         let ptr = self.global_base_pointer(Pointer::from(raw.alloc_id))?;
1130         let layout = self.layout_of(raw.ty)?;
1131         Ok(MPlaceTy::from_aligned_ptr(ptr, layout))
1132     }
1133
1134     /// Turn a place with a `dyn Trait` type into a place with the actual dynamic type.
1135     /// Also return some more information so drop doesn't have to run the same code twice.
1136     pub(super) fn unpack_dyn_trait(
1137         &self,
1138         mplace: MPlaceTy<'tcx, M::PointerTag>,
1139     ) -> InterpResult<'tcx, (ty::Instance<'tcx>, MPlaceTy<'tcx, M::PointerTag>)> {
1140         let vtable = mplace.vtable(); // also sanity checks the type
1141         let (instance, ty) = self.read_drop_type_from_vtable(vtable)?;
1142         let layout = self.layout_of(ty)?;
1143
1144         // More sanity checks
1145         if cfg!(debug_assertions) {
1146             let (size, align) = self.read_size_and_align_from_vtable(vtable)?;
1147             assert_eq!(size, layout.size);
1148             // only ABI alignment is preserved
1149             assert_eq!(align, layout.align.abi);
1150         }
1151
1152         let mplace = MPlaceTy { mplace: MemPlace { meta: MemPlaceMeta::None, ..*mplace }, layout };
1153         Ok((instance, mplace))
1154     }
1155 }