Skip to content

Commit 94c0f92

Browse files
author
Vytautas Astrauskas
committed
Update to support the updated API.
1 parent f0d8095 commit 94c0f92

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/machine.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,13 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
382382
}
383383
}
384384

385-
fn resolve_thread_local_allocation_id(extra: &Self::MemoryExtra, id: AllocId) -> AllocId {
386-
extra.tls.resolve_allocation(id)
385+
#[inline(always)]
386+
fn resolve_maybe_global_alloc(
387+
tcx: ty::query::TyCtxtAt<'tcx>,
388+
extra: &Self::MemoryExtra,
389+
id: AllocId,
390+
) -> Option<mir::interpret::GlobalAlloc<'tcx>> {
391+
extra.tls.resolve_allocation(*tcx, id)
387392
}
388393

389394
fn init_allocation_extra<'b>(

src/threads.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ use std::collections::hash_map::Entry;
55

66
use log::trace;
77

8-
use rustc_middle::ty;
98
use rustc_data_structures::fx::FxHashMap;
109
use rustc_index::vec::{Idx, IndexVec};
10+
use rustc_middle::mir;
11+
use rustc_middle::ty;
1112

1213
use crate::*;
1314

@@ -234,13 +235,17 @@ impl ThreadLocalStorage {
234235
}
235236
/// For thread local allocation identifier `alloc_id`, retrieve the original
236237
/// static allocation identifier from which it was created.
237-
pub fn resolve_allocation(&self, alloc_id: AllocId) -> AllocId {
238+
pub fn resolve_allocation<'tcx>(
239+
&self,
240+
tcx: ty::TyCtxt<'tcx>,
241+
alloc_id: AllocId,
242+
) -> Option<mir::interpret::GlobalAlloc<'tcx>> {
238243
trace!("resolve_allocation(alloc_id: {:?})", alloc_id);
239244
if let Some(original_id) = self.thread_local_origin.borrow().get(&alloc_id) {
240245
trace!("resolve_allocation(alloc_id: {:?}) -> {:?}", alloc_id, original_id);
241-
*original_id
246+
tcx.alloc_map.lock().get(*original_id)
242247
} else {
243-
alloc_id
248+
tcx.alloc_map.lock().get(alloc_id)
244249
}
245250
}
246251
/// Set which thread is currently active.

0 commit comments

Comments
 (0)