mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 14:01:51 +00:00
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
This commit is contained in:
parent
2c28244cf0
commit
83b493018a
@ -42,13 +42,13 @@ impl Condvar {
|
|||||||
|
|
||||||
pub unsafe fn notify_one(&self) {
|
pub unsafe fn notify_one(&self) {
|
||||||
self.cnt.fetch_add(1, SeqCst);
|
self.cnt.fetch_add(1, SeqCst);
|
||||||
wasm32::atomic_notify(self.ptr(), 1);
|
wasm32::memory_atomic_notify(self.ptr(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn notify_all(&self) {
|
pub unsafe fn notify_all(&self) {
|
||||||
self.cnt.fetch_add(1, SeqCst);
|
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) {
|
pub unsafe fn wait(&self, mutex: &Mutex) {
|
||||||
@ -62,7 +62,7 @@ impl Condvar {
|
|||||||
// wake us up once we're asleep.
|
// wake us up once we're asleep.
|
||||||
let ticket = self.cnt.load(SeqCst) as i32;
|
let ticket = self.cnt.load(SeqCst) as i32;
|
||||||
mutex.unlock();
|
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)
|
// 0 == woken, 1 == not equal to `ticket`, 2 == timeout (shouldn't happen)
|
||||||
debug_assert!(val == 0 || val == 1);
|
debug_assert!(val == 0 || val == 1);
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
@ -76,7 +76,7 @@ impl Condvar {
|
|||||||
|
|
||||||
// If the return value is 2 then a timeout happened, so we return
|
// If the return value is 2 then a timeout happened, so we return
|
||||||
// `false` as we weren't actually notified.
|
// `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();
|
mutex.lock();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ impl Mutex {
|
|||||||
|
|
||||||
pub unsafe fn lock(&self) {
|
pub unsafe fn lock(&self) {
|
||||||
while !self.try_lock() {
|
while !self.try_lock() {
|
||||||
let val = wasm32::i32_atomic_wait(
|
let val = wasm32::memory_atomic_wait32(
|
||||||
self.ptr(),
|
self.ptr(),
|
||||||
1, // we expect our mutex is locked
|
1, // we expect our mutex is locked
|
||||||
-1, // wait infinitely
|
-1, // wait infinitely
|
||||||
@ -40,7 +40,7 @@ impl Mutex {
|
|||||||
pub unsafe fn unlock(&self) {
|
pub unsafe fn unlock(&self) {
|
||||||
let prev = self.locked.swap(0, SeqCst);
|
let prev = self.locked.swap(0, SeqCst);
|
||||||
debug_assert_eq!(prev, 1);
|
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]
|
#[inline]
|
||||||
@ -91,7 +91,7 @@ impl ReentrantMutex {
|
|||||||
pub unsafe fn lock(&self) {
|
pub unsafe fn lock(&self) {
|
||||||
let me = thread::my_id();
|
let me = thread::my_id();
|
||||||
while let Err(owner) = self._try_lock(me) {
|
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);
|
debug_assert!(val == 0 || val == 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ impl ReentrantMutex {
|
|||||||
match *self.recursions.get() {
|
match *self.recursions.get() {
|
||||||
0 => {
|
0 => {
|
||||||
self.owner.swap(0, SeqCst);
|
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,
|
ref mut n => *n -= 1,
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ impl Thread {
|
|||||||
while nanos > 0 {
|
while nanos > 0 {
|
||||||
let amt = cmp::min(i64::MAX as u128, nanos);
|
let amt = cmp::min(i64::MAX as u128, nanos);
|
||||||
let mut x = 0;
|
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);
|
debug_assert_eq!(val, 2);
|
||||||
nanos -= amt;
|
nanos -= amt;
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 45340c0e2fdadf2f131ef43cb683b5cafab0ff15
|
Subproject commit 311d56cd91609c1c1c0370cbd2ece8e3048653a5
|
Loading…
Reference in New Issue
Block a user