@@ -168,7 +168,7 @@ impl MemoryExtra {
168168 "linux" => {
169169 // "__cxa_thread_atexit_impl"
170170 // This should be all-zero, pointer-sized.
171- let layout = this. layout_of ( this . tcx . types . usize ) ? ;
171+ let layout = this. machine . layouts . usize ;
172172 let place = this. allocate ( layout, MiriMemoryKind :: Machine . into ( ) ) ;
173173 this. write_scalar ( Scalar :: from_machine_usize ( 0 , this) , place. into ( ) ) ?;
174174 Self :: add_extern_static ( this, "__cxa_thread_atexit_impl" , place. ptr ) ;
@@ -178,7 +178,7 @@ impl MemoryExtra {
178178 "windows" => {
179179 // "_tls_used"
180180 // This is some obscure hack that is part of the Windows TLS story. It's a `u8`.
181- let layout = this. layout_of ( this . tcx . types . u8 ) ? ;
181+ let layout = this. machine . layouts . u8 ;
182182 let place = this. allocate ( layout, MiriMemoryKind :: Machine . into ( ) ) ;
183183 this. write_scalar ( Scalar :: from_u8 ( 0 ) , place. into ( ) ) ?;
184184 Self :: add_extern_static ( this, "_tls_used" , place. ptr ) ;
@@ -190,16 +190,26 @@ impl MemoryExtra {
190190}
191191
192192/// Precomputed layouts of primitive types
193- pub ( crate ) struct PrimitiveLayouts < ' tcx > {
194- pub ( crate ) i32 : TyAndLayout < ' tcx > ,
195- pub ( crate ) u32 : TyAndLayout < ' tcx > ,
193+ pub struct PrimitiveLayouts < ' tcx > {
194+ pub unit : TyAndLayout < ' tcx > ,
195+ pub i8 : TyAndLayout < ' tcx > ,
196+ pub i32 : TyAndLayout < ' tcx > ,
197+ pub isize : TyAndLayout < ' tcx > ,
198+ pub u8 : TyAndLayout < ' tcx > ,
199+ pub u32 : TyAndLayout < ' tcx > ,
200+ pub usize : TyAndLayout < ' tcx > ,
196201}
197202
198203impl < ' mir , ' tcx : ' mir > PrimitiveLayouts < ' tcx > {
199204 fn new ( layout_cx : LayoutCx < ' tcx , TyCtxt < ' tcx > > ) -> Result < Self , LayoutError < ' tcx > > {
200205 Ok ( Self {
206+ unit : layout_cx. layout_of ( layout_cx. tcx . mk_unit ( ) ) ?,
207+ i8 : layout_cx. layout_of ( layout_cx. tcx . types . i8 ) ?,
201208 i32 : layout_cx. layout_of ( layout_cx. tcx . types . i32 ) ?,
209+ isize : layout_cx. layout_of ( layout_cx. tcx . types . isize ) ?,
210+ u8 : layout_cx. layout_of ( layout_cx. tcx . types . u8 ) ?,
202211 u32 : layout_cx. layout_of ( layout_cx. tcx . types . u32 ) ?,
212+ usize : layout_cx. layout_of ( layout_cx. tcx . types . usize ) ?,
203213 } )
204214 }
205215}
@@ -242,8 +252,6 @@ pub struct Evaluator<'tcx> {
242252 pub ( crate ) time_anchor : Instant ,
243253
244254 /// Precomputed `TyLayout`s for primitive data types that are commonly used inside Miri.
245- /// FIXME: Search through the rest of the codebase for more layout_of() calls that
246- /// could be stored here.
247255 pub ( crate ) layouts : PrimitiveLayouts < ' tcx > ,
248256}
249257
0 commit comments