]> git.lizzy.rs Git - rust.git/blobdiff - src/shims/tls.rs
Replace deprecated `collections::Bound`
[rust.git] / src / shims / tls.rs
index 4a0d5fc22ad6150c23cd3f8db2c54eee30f5de6f..3339e3bee19990d2378759a9803fca3d842abdbf 100644 (file)
@@ -9,6 +9,7 @@
 use rustc_data_structures::fx::FxHashMap;
 use rustc_middle::ty;
 use rustc_target::abi::{Size, HasDataLayout};
+use rustc_target::spec::abi::Abi;
 
 use crate::*;
 
@@ -65,7 +66,7 @@ impl<'tcx> TlsData<'tcx> {
     pub fn create_tls_key(&mut self, dtor: Option<ty::Instance<'tcx>>, max_size: Size) -> InterpResult<'tcx, TlsKey> {
         let new_key = self.next_key;
         self.next_key += 1;
-        self.keys.insert(new_key, TlsEntry { data: Default::default(), dtor }).unwrap_none();
+        self.keys.try_insert(new_key, TlsEntry { data: Default::default(), dtor }).unwrap();
         trace!("New TLS key allocated: {} with dtor {:?}", new_key, dtor);
 
         if max_size.bits() < 128 && new_key >= (1u128 << max_size.bits() as u128) {
@@ -173,7 +174,7 @@ fn fetch_tls_dtor(
         key: Option<TlsKey>,
         thread_id: ThreadId,
     ) -> Option<(ty::Instance<'tcx>, Scalar<Tag>, TlsKey)> {
-        use std::collections::Bound::*;
+        use std::ops::Bound::*;
 
         let thread_local = &mut self.keys;
         let start = match key {
@@ -244,8 +245,9 @@ fn schedule_windows_tls_dtors(&mut self) -> InterpResult<'tcx> {
         let ret_place = MPlaceTy::dangling(this.machine.layouts.unit, this).into();
         this.call_function(
             thread_callback,
+            Abi::System { unwind: false },
             &[Scalar::null_ptr(this).into(), reason.into(), Scalar::null_ptr(this).into()],
-            Some(ret_place),
+            Some(&ret_place),
             StackPopCleanup::None { cleanup: true },
         )?;
 
@@ -266,8 +268,9 @@ fn schedule_macos_tls_dtor(&mut self) -> InterpResult<'tcx, bool> {
             let ret_place = MPlaceTy::dangling(this.machine.layouts.unit, this).into();
             this.call_function(
                 instance,
+                Abi::C { unwind: false },
                 &[data.into()],
-                Some(ret_place),
+                Some(&ret_place),
                 StackPopCleanup::None { cleanup: true },
             )?;
 
@@ -306,8 +309,9 @@ fn schedule_next_pthread_tls_dtor(&mut self) -> InterpResult<'tcx, bool> {
             let ret_place = MPlaceTy::dangling(this.machine.layouts.unit, this).into();
             this.call_function(
                 instance,
+                Abi::C { unwind: false },
                 &[ptr.into()],
-                Some(ret_place),
+                Some(&ret_place),
                 StackPopCleanup::None { cleanup: true },
             )?;
 
@@ -340,7 +344,7 @@ fn schedule_next_tls_dtor_for_active_thread(&mut self) -> InterpResult<'tcx> {
             // This is the first time we got asked to schedule a destructor. The
             // Windows schedule destructor function must be called exactly once,
             // this is why it is in this block.
-            if this.tcx.sess.target.target.target_os == "windows" {
+            if this.tcx.sess.target.os == "windows" {
                 // On Windows, we signal that the thread quit by starting the
                 // relevant function, reenabling the thread, and going back to
                 // the scheduler.
@@ -348,6 +352,9 @@ fn schedule_next_tls_dtor_for_active_thread(&mut self) -> InterpResult<'tcx> {
                 return Ok(())
             }
         }
+        // The remaining dtors make some progress each time around the scheduler loop,
+        // until they return `false` to indicate that they are done.
+
         // The macOS thread wide destructor runs "before any TLS slots get
         // freed", so do that first.
         if this.schedule_macos_tls_dtor()? {
@@ -364,7 +371,7 @@ fn schedule_next_tls_dtor_for_active_thread(&mut self) -> InterpResult<'tcx> {
 
         // All dtors done!
         this.machine.tls.delete_all_thread_tls(active_thread);
-        this.thread_terminated();
+        this.thread_terminated()?;
 
         Ok(())
     }