@@ -168,7 +168,7 @@ impl MemoryExtra {
168
168
"linux" => {
169
169
// "__cxa_thread_atexit_impl"
170
170
// This should be all-zero, pointer-sized.
171
- let layout = this. layout_of ( this . tcx . types . usize ) ? ;
171
+ let layout = this. machine . layouts . usize ;
172
172
let place = this. allocate ( layout, MiriMemoryKind :: Machine . into ( ) ) ;
173
173
this. write_scalar ( Scalar :: from_machine_usize ( 0 , this) , place. into ( ) ) ?;
174
174
Self :: add_extern_static ( this, "__cxa_thread_atexit_impl" , place. ptr ) ;
@@ -178,7 +178,7 @@ impl MemoryExtra {
178
178
"windows" => {
179
179
// "_tls_used"
180
180
// 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 ;
182
182
let place = this. allocate ( layout, MiriMemoryKind :: Machine . into ( ) ) ;
183
183
this. write_scalar ( Scalar :: from_u8 ( 0 ) , place. into ( ) ) ?;
184
184
Self :: add_extern_static ( this, "_tls_used" , place. ptr ) ;
@@ -190,16 +190,26 @@ impl MemoryExtra {
190
190
}
191
191
192
192
/// 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 > ,
196
201
}
197
202
198
203
impl < ' mir , ' tcx : ' mir > PrimitiveLayouts < ' tcx > {
199
204
fn new ( layout_cx : LayoutCx < ' tcx , TyCtxt < ' tcx > > ) -> Result < Self , LayoutError < ' tcx > > {
200
205
Ok ( Self {
206
+ unit : layout_cx. layout_of ( layout_cx. tcx . mk_unit ( ) ) ?,
207
+ i8 : layout_cx. layout_of ( layout_cx. tcx . types . i8 ) ?,
201
208
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 ) ?,
202
211
u32 : layout_cx. layout_of ( layout_cx. tcx . types . u32 ) ?,
212
+ usize : layout_cx. layout_of ( layout_cx. tcx . types . usize ) ?,
203
213
} )
204
214
}
205
215
}
@@ -242,8 +252,6 @@ pub struct Evaluator<'tcx> {
242
252
pub ( crate ) time_anchor : Instant ,
243
253
244
254
/// 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.
247
255
pub ( crate ) layouts : PrimitiveLayouts < ' tcx > ,
248
256
}
249
257
0 commit comments