Skip to content

Commit 61888e6

Browse files
author
Vytautas Astrauskas
committed
Update to support the updated API.
1 parent e7a51fc commit 61888e6

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/machine.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use rustc_middle::ty::{
1616
self,
1717
layout::{LayoutOf, Size},
1818
Ty,
19+
query::TyCtxtAt,
1920
};
2021
use rustc_ast::attr;
2122
use rustc_span::{source_map::Span, symbol::{sym, Symbol}};
@@ -388,8 +389,13 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
388389
}
389390
}
390391

391-
fn resolve_thread_local_allocation_id(extra: &Self::MemoryExtra, id: AllocId) -> AllocId {
392-
extra.tls.resolve_allocation(id)
392+
#[inline(always)]
393+
fn resolve_maybe_global_alloc(
394+
tcx: TyCtxtAt<'tcx>,
395+
extra: &Self::MemoryExtra,
396+
id: AllocId,
397+
) -> Option<mir::interpret::GlobalAlloc<'tcx>> {
398+
extra.tls.resolve_allocation(*tcx, id)
393399
}
394400

395401
fn init_allocation_extra<'b>(

src/threads.rs

Lines changed: 9 additions & 4 deletions
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)