]> git.lizzy.rs Git - rust.git/commitdiff
added machine hooks to track deallocations
authorOzaren <krishna.sd.2012@gmail.com>
Thu, 9 Apr 2020 18:48:06 +0000 (14:48 -0400)
committerOzaren <krishna.sd.2012@gmail.com>
Fri, 10 Apr 2020 17:17:55 +0000 (13:17 -0400)
src/librustc_mir/interpret/machine.rs
src/librustc_mir/interpret/memory.rs

index 23e39f433f53b1ffcef60a091f32804b3f8974a6..fd67b088c93cff162b2f5363e9aa4936e6924619 100644 (file)
@@ -254,6 +254,14 @@ fn init_allocation_extra<'b>(
         kind: Option<MemoryKind<Self::MemoryKind>>,
     ) -> (Cow<'b, Allocation<Self::PointerTag, Self::AllocExtra>>, Self::PointerTag);
 
+    /// Called to notify the machine before a deallocation occurs.
+    fn before_deallocation(
+        _memory_extra: &mut Self::MemoryExtra,
+        _id: AllocId,
+    ) -> InterpResult<'tcx> {
+        Ok(())
+    }
+
     /// Return the "base" tag for the given *global* allocation: the one that is used for direct
     /// accesses to this static/const/fn allocation. If `id` is not a global allocation,
     /// this will return an unusable tag (i.e., accesses will be UB)!
index c16c59715e40c4992979552b19e9570a885c23ac..539537e9de80c414fe6b19d8622466fe5d3c510d 100644 (file)
@@ -254,6 +254,8 @@ pub fn deallocate(
             );
         }
 
+        M::before_deallocation(&mut self.extra, ptr.alloc_id)?;
+
         let (alloc_kind, mut alloc) = match self.alloc_map.remove(&ptr.alloc_id) {
             Some(alloc) => alloc,
             None => {