]> git.lizzy.rs Git - rust.git/blobdiff - src/thread.rs
Auto merge of #2427 - Nilstrieb:doc-fix, r=saethlin
[rust.git] / src / thread.rs
index 420eeb810fd874a75fb77a45a6bbea1211c10915..683694f482eaab896b441574de2674d727842271 100644 (file)
@@ -70,7 +70,7 @@ fn from(id: u32) -> Self {
 }
 
 impl ThreadId {
-    pub fn to_u32_scalar(&self) -> Scalar<Tag> {
+    pub fn to_u32_scalar(&self) -> Scalar<Provenance> {
         Scalar::from_u32(self.0)
     }
 }
@@ -112,7 +112,7 @@ pub struct Thread<'mir, 'tcx> {
     thread_name: Option<Vec<u8>>,
 
     /// The virtual call stack.
-    stack: Vec<Frame<'mir, 'tcx, Tag, FrameData<'tcx>>>,
+    stack: Vec<Frame<'mir, 'tcx, Provenance, FrameData<'tcx>>>,
 
     /// The join status.
     join_status: ThreadJoinStatus,
@@ -120,10 +120,10 @@ pub struct Thread<'mir, 'tcx> {
     /// The temporary used for storing the argument of
     /// the call to `miri_start_panic` (the panic payload) when unwinding.
     /// This is pointer-sized, and matches the `Payload` type in `src/libpanic_unwind/miri.rs`.
-    pub(crate) panic_payload: Option<Scalar<Tag>>,
+    pub(crate) panic_payload: Option<Scalar<Provenance>>,
 
     /// Last OS error location in memory. It is a 32-bit integer.
-    pub(crate) last_error: Option<MPlaceTy<'tcx, Tag>>,
+    pub(crate) last_error: Option<MPlaceTy<'tcx, Provenance>>,
 }
 
 impl<'mir, 'tcx> Thread<'mir, 'tcx> {
@@ -227,7 +227,7 @@ pub struct ThreadManager<'mir, 'tcx> {
     pub(crate) sync: SynchronizationState,
     /// A mapping from a thread-local static to an allocation id of a thread
     /// specific allocation.
-    thread_local_alloc_ids: RefCell<FxHashMap<(DefId, ThreadId), Pointer<Tag>>>,
+    thread_local_alloc_ids: RefCell<FxHashMap<(DefId, ThreadId), Pointer<Provenance>>>,
     /// A flag that indicates that we should change the active thread.
     yield_active_thread: bool,
     /// Callbacks that are called once the specified time passes.
@@ -256,7 +256,7 @@ fn default() -> Self {
 impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
     /// Check if we have an allocation for the given thread local static for the
     /// active thread.
-    fn get_thread_local_alloc_id(&self, def_id: DefId) -> Option<Pointer<Tag>> {
+    fn get_thread_local_alloc_id(&self, def_id: DefId) -> Option<Pointer<Provenance>> {
         self.thread_local_alloc_ids.borrow().get(&(def_id, self.active_thread)).cloned()
     }
 
@@ -264,7 +264,7 @@ fn get_thread_local_alloc_id(&self, def_id: DefId) -> Option<Pointer<Tag>> {
     /// static for the active thread.
     ///
     /// Panics if a thread local is initialized twice for the same thread.
-    fn set_thread_local_alloc(&self, def_id: DefId, ptr: Pointer<Tag>) {
+    fn set_thread_local_alloc(&self, def_id: DefId, ptr: Pointer<Provenance>) {
         self.thread_local_alloc_ids
             .borrow_mut()
             .try_insert((def_id, self.active_thread), ptr)
@@ -272,15 +272,23 @@ fn set_thread_local_alloc(&self, def_id: DefId, ptr: Pointer<Tag>) {
     }
 
     /// Borrow the stack of the active thread.
-    pub fn active_thread_stack(&self) -> &[Frame<'mir, 'tcx, Tag, FrameData<'tcx>>] {
+    pub fn active_thread_stack(&self) -> &[Frame<'mir, 'tcx, Provenance, FrameData<'tcx>>] {
         &self.threads[self.active_thread].stack
     }
 
     /// Mutably borrow the stack of the active thread.
-    fn active_thread_stack_mut(&mut self) -> &mut Vec<Frame<'mir, 'tcx, Tag, FrameData<'tcx>>> {
+    fn active_thread_stack_mut(
+        &mut self,
+    ) -> &mut Vec<Frame<'mir, 'tcx, Provenance, FrameData<'tcx>>> {
         &mut self.threads[self.active_thread].stack
     }
 
+    pub fn all_stacks(
+        &self,
+    ) -> impl Iterator<Item = &[Frame<'mir, 'tcx, Provenance, FrameData<'tcx>>]> {
+        self.threads.iter().map(|t| &t.stack[..])
+    }
+
     /// Create a new thread and returns its id.
     fn create_thread(&mut self) -> ThreadId {
         let new_thread_id = ThreadId::new(self.threads.len());
@@ -464,7 +472,7 @@ fn get_ready_callback(&mut self) -> Option<(ThreadId, TimeoutCallback<'mir, 'tcx
     fn thread_terminated(
         &mut self,
         mut data_race: Option<&mut data_race::GlobalState>,
-    ) -> Vec<Pointer<Tag>> {
+    ) -> Vec<Pointer<Provenance>> {
         let mut free_tls_statics = Vec::new();
         {
             let mut thread_local_statics = self.thread_local_alloc_ids.borrow_mut();
@@ -585,7 +593,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
     fn get_or_create_thread_local_alloc(
         &mut self,
         def_id: DefId,
-    ) -> InterpResult<'tcx, Pointer<Tag>> {
+    ) -> InterpResult<'tcx, Pointer<Provenance>> {
         let this = self.eval_context_mut();
         let tcx = this.tcx;
         if let Some(old_alloc) = this.machine.threads.get_thread_local_alloc_id(def_id) {
@@ -682,13 +690,15 @@ fn enable_thread(&mut self, thread_id: ThreadId) {
     }
 
     #[inline]
-    fn active_thread_stack(&self) -> &[Frame<'mir, 'tcx, Tag, FrameData<'tcx>>] {
+    fn active_thread_stack(&self) -> &[Frame<'mir, 'tcx, Provenance, FrameData<'tcx>>] {
         let this = self.eval_context_ref();
         this.machine.threads.active_thread_stack()
     }
 
     #[inline]
-    fn active_thread_stack_mut(&mut self) -> &mut Vec<Frame<'mir, 'tcx, Tag, FrameData<'tcx>>> {
+    fn active_thread_stack_mut(
+        &mut self,
+    ) -> &mut Vec<Frame<'mir, 'tcx, Provenance, FrameData<'tcx>>> {
         let this = self.eval_context_mut();
         this.machine.threads.active_thread_stack_mut()
     }