Skip to content

Commit

Permalink
Update to support the updated API.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vytautas Astrauskas committed Apr 1, 2020
1 parent e7a51fc commit 61888e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use rustc_middle::ty::{
self,
layout::{LayoutOf, Size},
Ty,
query::TyCtxtAt,
};
use rustc_ast::attr;
use rustc_span::{source_map::Span, symbol::{sym, Symbol}};
Expand Down Expand Up @@ -388,8 +389,13 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
}
}

fn resolve_thread_local_allocation_id(extra: &Self::MemoryExtra, id: AllocId) -> AllocId {
extra.tls.resolve_allocation(id)
#[inline(always)]
fn resolve_maybe_global_alloc(
tcx: TyCtxtAt<'tcx>,
extra: &Self::MemoryExtra,
id: AllocId,
) -> Option<mir::interpret::GlobalAlloc<'tcx>> {
extra.tls.resolve_allocation(*tcx, id)
}

fn init_allocation_extra<'b>(
Expand Down
13 changes: 9 additions & 4 deletions src/threads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ use std::collections::hash_map::Entry;

use log::trace;

use rustc_middle::ty;
use rustc_data_structures::fx::FxHashMap;
use rustc_index::vec::{Idx, IndexVec};
use rustc_middle::mir;
use rustc_middle::ty;

use crate::*;

Expand Down Expand Up @@ -234,13 +235,17 @@ impl ThreadLocalStorage {
}
/// For thread local allocation identifier `alloc_id`, retrieve the original
/// static allocation identifier from which it was created.
pub fn resolve_allocation(&self, alloc_id: AllocId) -> AllocId {
pub fn resolve_allocation<'tcx>(
&self,
tcx: ty::TyCtxt<'tcx>,
alloc_id: AllocId,
) -> Option<mir::interpret::GlobalAlloc<'tcx>> {
trace!("resolve_allocation(alloc_id: {:?})", alloc_id);
if let Some(original_id) = self.thread_local_origin.borrow().get(&alloc_id) {
trace!("resolve_allocation(alloc_id: {:?}) -> {:?}", alloc_id, original_id);
*original_id
tcx.alloc_map.lock().get(*original_id)
} else {
alloc_id
tcx.alloc_map.lock().get(alloc_id)
}
}
/// Set which thread is currently active.
Expand Down

0 comments on commit 61888e6

Please sign in to comment.