@@ -320,15 +320,16 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
320
320
/// this machine use the same pointer tag, so it is indirected through
321
321
/// `M::static_with_default_tag`.
322
322
fn get_static_alloc (
323
- tcx : TyCtxtAt < ' a , ' tcx , ' tcx > ,
324
323
id : AllocId ,
324
+ tcx : TyCtxtAt < ' a , ' tcx , ' tcx > ,
325
+ memory_extra : & M :: MemoryExtra ,
325
326
) -> EvalResult < ' tcx , Cow < ' tcx , Allocation < M :: PointerTag , M :: AllocExtra > > > {
326
327
let alloc = tcx. alloc_map . lock ( ) . get ( id) ;
327
328
let def_id = match alloc {
328
329
Some ( AllocType :: Memory ( mem) ) => {
329
330
// We got tcx memory. Let the machine figure out whether and how to
330
331
// turn that into memory with the right pointer tag.
331
- return Ok ( M :: adjust_static_allocation ( mem) )
332
+ return Ok ( M :: adjust_static_allocation ( mem, memory_extra ) )
332
333
}
333
334
Some ( AllocType :: Function ( ..) ) => {
334
335
return err ! ( DerefFunctionPointer )
@@ -342,7 +343,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
342
343
// We got a "lazy" static that has not been computed yet, do some work
343
344
trace ! ( "static_alloc: Need to compute {:?}" , def_id) ;
344
345
if tcx. is_foreign_item ( def_id) {
345
- return M :: find_foreign_static ( tcx, def_id ) ;
346
+ return M :: find_foreign_static ( def_id , tcx, memory_extra ) ;
346
347
}
347
348
let instance = Instance :: mono ( tcx. tcx , def_id) ;
348
349
let gid = GlobalId {
@@ -362,7 +363,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
362
363
let allocation = tcx. alloc_map . lock ( ) . unwrap_memory ( raw_const. alloc_id ) ;
363
364
// We got tcx memory. Let the machine figure out whether and how to
364
365
// turn that into memory with the right pointer tag.
365
- M :: adjust_static_allocation ( allocation)
366
+ M :: adjust_static_allocation ( allocation, memory_extra )
366
367
} )
367
368
}
368
369
@@ -372,7 +373,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
372
373
// `get_static_alloc` that we can actually use directly without inserting anything anywhere.
373
374
// So the error type is `EvalResult<'tcx, &Allocation<M::PointerTag>>`.
374
375
let a = self . alloc_map . get_or ( id, || {
375
- let alloc = Self :: get_static_alloc ( self . tcx , id ) . map_err ( Err ) ?;
376
+ let alloc = Self :: get_static_alloc ( id , self . tcx , & self . extra ) . map_err ( Err ) ?;
376
377
match alloc {
377
378
Cow :: Borrowed ( alloc) => {
378
379
// We got a ref, cheaply return that as an "error" so that the
@@ -401,10 +402,11 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
401
402
id : AllocId ,
402
403
) -> EvalResult < ' tcx , & mut Allocation < M :: PointerTag , M :: AllocExtra > > {
403
404
let tcx = self . tcx ;
405
+ let memory_extra = & self . extra ;
404
406
let a = self . alloc_map . get_mut_or ( id, || {
405
407
// Need to make a copy, even if `get_static_alloc` is able
406
408
// to give us a cheap reference.
407
- let alloc = Self :: get_static_alloc ( tcx, id ) ?;
409
+ let alloc = Self :: get_static_alloc ( id , tcx, memory_extra ) ?;
408
410
if alloc. mutability == Mutability :: Immutable {
409
411
return err ! ( ModifiedConstantMemory ) ;
410
412
}
0 commit comments