]> git.lizzy.rs Git - rust.git/commitdiff
Update to support the updated API.
authorVytautas Astrauskas <astrauv@amazon.com>
Wed, 1 Apr 2020 23:28:33 +0000 (16:28 -0700)
committerVytautas Astrauskas <astrauv@amazon.com>
Mon, 27 Apr 2020 21:23:32 +0000 (14:23 -0700)
src/machine.rs
src/threads.rs

index 9d1fa9b78c32d984c955e2615a50776c9720355d..e6fea672c608cfba87e2fe9579af4a76d16d1143 100644 (file)
@@ -464,8 +464,13 @@ fn canonical_alloc_id(mem: &Memory<'mir, 'tcx, Self>, id: AllocId) -> AllocId {
         }
     }
 
-    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: ty::query::TyCtxtAt<'tcx>,
+        extra: &Self::MemoryExtra,
+        id: AllocId,
+    ) -> Option<mir::interpret::GlobalAlloc<'tcx>> {
+        extra.tls.resolve_allocation(*tcx, id)
     }
 
     fn init_allocation_extra<'b>(
index 14ee58c2ee3e6960b1ea8e396840691a58a78169..618713e3c3deaf5c2671167efa2276abeb7ac456 100644 (file)
@@ -5,9 +5,10 @@
 
 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::*;
 
@@ -234,13 +235,17 @@ pub fn get_or_register_allocation(&self, tcx: ty::TyCtxt<'_>, original_id: Alloc
     }
     /// 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.