1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

isolate: work around a rust compiler bug

This commit is contained in:
Bert Belder 2018-10-03 01:10:57 -07:00
parent 4eeda9ea27
commit 97e08a6fab
No known key found for this signature in database
GPG key ID: 7A77887B2E2ED461

View file

@ -14,6 +14,7 @@ use libc::c_void;
use std; use std;
use std::ffi::CStr; use std::ffi::CStr;
use std::ffi::CString; use std::ffi::CString;
use std::sync::atomic;
use std::sync::mpsc; use std::sync::mpsc;
use std::sync::Arc; use std::sync::Arc;
use std::sync::Mutex; use std::sync::Mutex;
@ -193,6 +194,14 @@ impl Isolate {
} }
fn ntasks_decrement(&mut self) { fn ntasks_decrement(&mut self) {
// Do something that has no effect. This is done to work around a spooky
// bug that happens in release mode only (presumably a compiler bug), that
// causes nsize to unexpectedly contain zero.
// TODO: remove this workaround when no longer necessary.
#[allow(unused)]
static UNUSED: atomic::AtomicIsize = atomic::AtomicIsize::new(0);
UNUSED.fetch_add(self.ntasks as isize, atomic::Ordering::AcqRel);
// Actually decrement the tasks counter here.
self.ntasks = self.ntasks - 1; self.ntasks = self.ntasks - 1;
assert!(self.ntasks >= 0); assert!(self.ntasks >= 0);
} }