Re: C++11 atomics in Mozilla

2013-01-28 Thread Ehsan Akhgari
On 2013-01-28 12:48 AM, Brian Smith wrote: Joshua Cranmer wrote: In bug 732043, I want to add a mozilla::Atomic class that lets us use C++11 atomics where available and fallback to compiler intrinsics where C++11 atomics are not implemented (which amounts to gcc 4.4 and Visual Studio 2010 or ear

Re: C++11 atomics in Mozilla

2013-01-27 Thread Brian Smith
Joshua Cranmer wrote: > On 1/27/2013 11:48 PM, Brian Smith wrote: > > FWIW, in cases like this, I would rather we just use the C++11 API > > directly even if it means dropping support for common but > > out-of-date compilers like gcc 4.4 and VS2010. > > I personally prefer an API style where the m

Re: C++11 atomics in Mozilla

2013-01-27 Thread Joshua Cranmer
On 1/27/2013 11:48 PM, Brian Smith wrote: Joshua Cranmer wrote: In bug 732043, I want to add a mozilla::Atomic class that lets us use C++11 atomics where available and fallback to compiler intrinsics where C++11 atomics are not implemented (which amounts to gcc 4.4 and Visual Studio 2010 or earl

Re: C++11 atomics in Mozilla

2013-01-27 Thread Brian Smith
Joshua Cranmer wrote: > In bug 732043, I want to add a mozilla::Atomic class > that lets us use C++11 atomics where available and fallback to > compiler intrinsics where C++11 atomics are not implemented > (which amounts to gcc 4.4 and Visual Studio 2010 or earlier). How far are we from Visual Stu

Re: C++11 atomics in Mozilla

2012-12-13 Thread Boris Zbarsky
On 12/14/12 1:48 AM, Justin Lebar wrote: FWIW, I once tried changing all of our atomic string refcounting to non-atomic operations and could not eke out a performance (or stability) difference on x64. This was despite the fact that I was able to generate profiles where the atomic string refcount

Re: C++11 atomics in Mozilla

2012-12-13 Thread Justin Lebar
> Is code like this safe in the C++1 Unordered model? > Thread 1: > int x = obj->v; > obj->Release(); > Thread 2: > obj->Release(); > where obj's destructor trashes obj->v. > The potential hazard is if thread 1's obj->Release() atomic decrement is > reordered to run before the obj->v load has

Re: C++11 atomics in Mozilla

2012-12-13 Thread Robert O'Callahan
On Fri, Dec 14, 2012 at 12:33 PM, Joshua Cranmer wrote: > 3. Similar to #2, the ideal version of a reference counter would be > mozilla::Atomic (which would make threadsafe > refcounting cheaper on our ARM platforms if we compiled with gcc 4.6 or > clang 3.1 or newer). However, I'm not sure that n

C++11 atomics in Mozilla

2012-12-13 Thread Joshua Cranmer
As you may or may not be aware, one of the goodies that comes in C++11 is the introduction of an explicit memory model as well as proper support for multithreaded code. One important piece of this is std::atomic, which provides an interoperable way to do (potentially lockless) atomic operations