From 83b493018a31dc6510058a720f386de8ecac4577 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 18 Jul 2020 08:43:09 -0700 Subject: [PATCH] Update stdarch submodule This commit updates the src/stdarch submodule primarily to include rust-lang/stdarch#874 which updated and revamped WebAssembly SIMD intrinsics and renamed WebAssembly atomics intrinsics. This is all unstable surface area of the standard library so the changes should be ok here. The SIMD updates also enable SIMD intrinsics to be used by any program any any time, yay! cc #74372, a tracking issue I've opened for the stabilization of SIMD intrinsics --- library/std/src/sys/wasm/condvar_atomics.rs | 8 ++++---- library/std/src/sys/wasm/mutex_atomics.rs | 8 ++++---- library/std/src/sys/wasm/thread.rs | 2 +- library/stdarch | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/library/std/src/sys/wasm/condvar_atomics.rs b/library/std/src/sys/wasm/condvar_atomics.rs index 1859cdd5a0ed8..d86bb60507be2 100644 --- a/library/std/src/sys/wasm/condvar_atomics.rs +++ b/library/std/src/sys/wasm/condvar_atomics.rs @@ -42,13 +42,13 @@ impl Condvar { pub unsafe fn notify_one(&self) { self.cnt.fetch_add(1, SeqCst); - wasm32::atomic_notify(self.ptr(), 1); + wasm32::memory_atomic_notify(self.ptr(), 1); } #[inline] pub unsafe fn notify_all(&self) { self.cnt.fetch_add(1, SeqCst); - wasm32::atomic_notify(self.ptr(), u32::MAX); // -1 == "wake everyone" + wasm32::memory_atomic_notify(self.ptr(), u32::MAX); // -1 == "wake everyone" } pub unsafe fn wait(&self, mutex: &Mutex) { @@ -62,7 +62,7 @@ impl Condvar { // wake us up once we're asleep. let ticket = self.cnt.load(SeqCst) as i32; mutex.unlock(); - let val = wasm32::i32_atomic_wait(self.ptr(), ticket, -1); + let val = wasm32::memory_atomic_wait32(self.ptr(), ticket, -1); // 0 == woken, 1 == not equal to `ticket`, 2 == timeout (shouldn't happen) debug_assert!(val == 0 || val == 1); mutex.lock(); @@ -76,7 +76,7 @@ impl Condvar { // If the return value is 2 then a timeout happened, so we return // `false` as we weren't actually notified. - let ret = wasm32::i32_atomic_wait(self.ptr(), ticket, nanos as i64) != 2; + let ret = wasm32::memory_atomic_wait32(self.ptr(), ticket, nanos as i64) != 2; mutex.lock(); return ret; } diff --git a/library/std/src/sys/wasm/mutex_atomics.rs b/library/std/src/sys/wasm/mutex_atomics.rs index 268a53bb5641c..4b1a7c9b48141 100644 --- a/library/std/src/sys/wasm/mutex_atomics.rs +++ b/library/std/src/sys/wasm/mutex_atomics.rs @@ -26,7 +26,7 @@ impl Mutex { pub unsafe fn lock(&self) { while !self.try_lock() { - let val = wasm32::i32_atomic_wait( + let val = wasm32::memory_atomic_wait32( self.ptr(), 1, // we expect our mutex is locked -1, // wait infinitely @@ -40,7 +40,7 @@ impl Mutex { pub unsafe fn unlock(&self) { let prev = self.locked.swap(0, SeqCst); debug_assert_eq!(prev, 1); - wasm32::atomic_notify(self.ptr(), 1); // wake up one waiter, if any + wasm32::memory_atomic_notify(self.ptr(), 1); // wake up one waiter, if any } #[inline] @@ -91,7 +91,7 @@ impl ReentrantMutex { pub unsafe fn lock(&self) { let me = thread::my_id(); while let Err(owner) = self._try_lock(me) { - let val = wasm32::i32_atomic_wait(self.ptr(), owner as i32, -1); + let val = wasm32::memory_atomic_wait32(self.ptr(), owner as i32, -1); debug_assert!(val == 0 || val == 1); } } @@ -130,7 +130,7 @@ impl ReentrantMutex { match *self.recursions.get() { 0 => { self.owner.swap(0, SeqCst); - wasm32::atomic_notify(self.ptr() as *mut i32, 1); // wake up one waiter, if any + wasm32::memory_atomic_notify(self.ptr() as *mut i32, 1); // wake up one waiter, if any } ref mut n => *n -= 1, } diff --git a/library/std/src/sys/wasm/thread.rs b/library/std/src/sys/wasm/thread.rs index 0a11896a0048f..95a9230aa7888 100644 --- a/library/std/src/sys/wasm/thread.rs +++ b/library/std/src/sys/wasm/thread.rs @@ -40,7 +40,7 @@ impl Thread { while nanos > 0 { let amt = cmp::min(i64::MAX as u128, nanos); let mut x = 0; - let val = unsafe { wasm32::i32_atomic_wait(&mut x, 0, amt as i64) }; + let val = unsafe { wasm32::memory_atomic_wait32(&mut x, 0, amt as i64) }; debug_assert_eq!(val, 2); nanos -= amt; } diff --git a/library/stdarch b/library/stdarch index 45340c0e2fdad..311d56cd91609 160000 --- a/library/stdarch +++ b/library/stdarch @@ -1 +1 @@ -Subproject commit 45340c0e2fdadf2f131ef43cb683b5cafab0ff15 +Subproject commit 311d56cd91609c1c1c0370cbd2ece8e3048653a5