From 5790af6c8bbe8acd82cb0db4fc6f49dca301985a Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 2 Mar 2022 18:19:24 +0000 Subject: Issue #15 - Part 1: remove a number of old GCC hacks. --- build/autoconf/compiler-opts.m4 | 5 +++-- build/unix/build-gcc/build-gcc.sh | 2 +- dom/media/GraphDriver.cpp | 5 ----- dom/media/MediaManager.cpp | 31 ++++++++++++------------------- dom/media/MediaManager.h | 1 - dom/plugins/base/npfunctions.h | 4 ++-- dom/plugins/base/nptypes.h | 19 +++---------------- layout/style/nsCSSParser.cpp | 39 +++++++++++++++++++++++++++------------ python/pyyaml/ext/_yaml.c | 10 ++-------- xpcom/base/nscore.h | 8 -------- xpcom/glue/nsCOMPtr.h | 6 ++---- xpcom/string/nsTSubstring.h | 1 - 12 files changed, 52 insertions(+), 79 deletions(-) diff --git a/build/autoconf/compiler-opts.m4 b/build/autoconf/compiler-opts.m4 index 077a3e6f1..99990332f 100644 --- a/build/autoconf/compiler-opts.m4 +++ b/build/autoconf/compiler-opts.m4 @@ -16,7 +16,7 @@ dnl set DEVELOPER_OPTIONS early; MOZ_DEFAULT_COMPILER is usually the first non-s DEVELOPER_OPTIONS=, DEVELOPER_OPTIONS=1) -dnl Default to MSVC for win32 and gcc-4.2 for darwin +dnl Default to MSVC for win32 dnl ============================================================== if test -z "$CROSS_COMPILE"; then case "$target" in @@ -186,7 +186,8 @@ if test "$GNU_CC"; then if test -z "$CLANG_CC"; then case "$CC_VERSION" in - 4.* | 5.*) + 4.* | 5.* | 6.*) + AC_MSG_ERROR([Unsupported GCC version.]) ;; *) # Lifetime Dead Store Elimination level 2 (default in GCC6+) breaks Gecko. diff --git a/build/unix/build-gcc/build-gcc.sh b/build/unix/build-gcc/build-gcc.sh index df3bc5dfd..2c4d7b323 100755 --- a/build/unix/build-gcc/build-gcc.sh +++ b/build/unix/build-gcc/build-gcc.sh @@ -1,6 +1,6 @@ #!/bin/bash -gcc_version=4.8.5 +gcc_version=7.1.0 binutils_version=2.25.1 this_path=$(readlink -f $(dirname $0)) make_flags='-j12' diff --git a/dom/media/GraphDriver.cpp b/dom/media/GraphDriver.cpp index eacc7686f..0a38e2e24 100644 --- a/dom/media/GraphDriver.cpp +++ b/dom/media/GraphDriver.cpp @@ -28,11 +28,6 @@ StaticRefPtr AsyncCubebTask::sThreadPool; struct AutoProfilerUnregisterThread { - // The empty ctor is used to silence a pre-4.8.0 GCC unused variable warning. - AutoProfilerUnregisterThread() - { - } - ~AutoProfilerUnregisterThread() { profiler_unregister_thread(); diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index 1b7a05d38..0b6fd4b43 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -1260,13 +1260,6 @@ GetSources(MediaEngine *engine, MediaSourceEnum aSrcType, } } -// TODO: Remove once upgraded to GCC 4.8+ on linux. Bogus error on static func: -// error: 'this' was not captured for this lambda function - -static auto& MediaManager_GetInstance = MediaManager::GetInstance; -static auto& MediaManager_ToJSArray = MediaManager::ToJSArray; -static auto& MediaManager_AnonymizeDevices = MediaManager::AnonymizeDevices; - already_AddRefed MediaManager::SelectSettings( MediaStreamConstraints& aConstraints, @@ -1326,7 +1319,7 @@ MediaManager::SelectSettings( } } NS_DispatchToMainThread(NewRunnableFrom([id, badConstraint]() mutable { - RefPtr mgr = MediaManager_GetInstance(); + RefPtr mgr = MediaManager::GetInstance(); RefPtr p = mgr->mOutstandingCharPledges.Remove(id); if (p) { p->Resolve(badConstraint); @@ -1586,7 +1579,7 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId, fakeBackend = new MediaEngineDefault(); } if ((!fakeCams && hasVideo) || (!fakeMics && hasAudio)) { - RefPtr manager = MediaManager_GetInstance(); + RefPtr manager = MediaManager::GetInstance(); realBackend = manager->GetBackend(aWindowId); } @@ -1611,7 +1604,7 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId, SourceSet* handoff = result.release(); NS_DispatchToMainThread(NewRunnableFrom([id, handoff]() mutable { UniquePtr result(handoff); // grab result - RefPtr mgr = MediaManager_GetInstance(); + RefPtr mgr = MediaManager::GetInstance(); if (!mgr) { return NS_OK; } @@ -1884,7 +1877,7 @@ int MediaManager::AddDeviceChangeCallback(DeviceChangeCallback* aCallback) { bool fakeDeviceChangeEventOn = mPrefs.mFakeDeviceChangeEventOn; MediaManager::PostTask(NewTaskFrom([fakeDeviceChangeEventOn]() { - RefPtr manager = MediaManager_GetInstance(); + RefPtr manager = MediaManager::GetInstance(); manager->GetBackend(0)->AddDeviceChangeCallback(manager); if (fakeDeviceChangeEventOn) manager->GetBackend(0)->SetFakeDeviceChangeEvents(); @@ -2404,7 +2397,7 @@ MediaManager::EnumerateDevicesImpl(uint64_t aWindowId, p->Then([id, aWindowId, aVideoType, aAudioType, aFake](const nsCString& aOriginKey) mutable { MOZ_ASSERT(NS_IsMainThread()); - RefPtr mgr = MediaManager_GetInstance(); + RefPtr mgr = MediaManager::GetInstance(); RefPtr p = mgr->EnumerateRawDevices(aWindowId, aVideoType, aAudioType, aFake); @@ -2412,7 +2405,7 @@ MediaManager::EnumerateDevicesImpl(uint64_t aWindowId, UniquePtr devices(aDevices); // secondary result // Only run if window is still on our active list. - RefPtr mgr = MediaManager_GetInstance(); + RefPtr mgr = MediaManager::GetInstance(); if (!mgr) { return NS_OK; } @@ -2420,7 +2413,7 @@ MediaManager::EnumerateDevicesImpl(uint64_t aWindowId, if (!p || !mgr->IsWindowStillActive(aWindowId)) { return NS_OK; } - MediaManager_AnonymizeDevices(*devices, aOriginKey); + MediaManager::AnonymizeDevices(*devices, aOriginKey); p->Resolve(devices.release()); return NS_OK; }); @@ -2459,12 +2452,12 @@ MediaManager::EnumerateDevices(nsPIDOMWindowInner* aWindow, fake); p->Then([onSuccess, windowId, listener](SourceSet*& aDevices) mutable { UniquePtr devices(aDevices); // grab result - RefPtr mgr = MediaManager_GetInstance(); + RefPtr mgr = MediaManager::GetInstance(); mgr->RemoveFromWindowList(windowId, listener); - nsCOMPtr array = MediaManager_ToJSArray(*devices); + nsCOMPtr array = MediaManager::ToJSArray(*devices); onSuccess->OnSuccess(array); }, [onFailure, windowId, listener](MediaStreamError*& reason) mutable { - RefPtr mgr = MediaManager_GetInstance(); + RefPtr mgr = MediaManager::GetInstance(); mgr->RemoveFromWindowList(windowId, listener); onFailure->OnError(reason); }); @@ -2501,7 +2494,7 @@ MediaManager::GetUserMediaDevices(nsPIDOMWindowInner* aWindow, RefPtr task; if (!aCallID.Length() || aCallID == callID) { if (mActiveCallbacks.Get(callID, getter_AddRefs(task))) { - nsCOMPtr array = MediaManager_ToJSArray(*task->mSourceSet); + nsCOMPtr array = MediaManager::ToJSArray(*task->mSourceSet); onSuccess->OnSuccess(array); return NS_OK; } @@ -3286,7 +3279,7 @@ GetUserMediaCallbackMediaStreamListener::ApplyConstraintsToTrack( NS_DispatchToMainThread(NewRunnableFrom([id, windowId, rv, badConstraint]() mutable { MOZ_ASSERT(NS_IsMainThread()); - RefPtr mgr = MediaManager_GetInstance(); + RefPtr mgr = MediaManager::GetInstance(); if (!mgr) { return NS_OK; } diff --git a/dom/media/MediaManager.h b/dom/media/MediaManager.h index 548ddd938..92e1a2576 100644 --- a/dom/media/MediaManager.h +++ b/dom/media/MediaManager.h @@ -264,7 +264,6 @@ private: static nsresult GenerateUUID(nsAString& aResult); static nsresult AnonymizeId(nsAString& aId, const nsACString& aOriginKey); -public: // TODO: make private once we upgrade to GCC 4.8+ on linux. static void AnonymizeDevices(SourceSet& aDevices, const nsACString& aOriginKey); static already_AddRefed ToJSArray(SourceSet& aDevices); private: diff --git a/dom/plugins/base/npfunctions.h b/dom/plugins/base/npfunctions.h index 7638a6488..83c8a9762 100644 --- a/dom/plugins/base/npfunctions.h +++ b/dom/plugins/base/npfunctions.h @@ -189,8 +189,8 @@ typedef struct _NPNetscapeFuncs { #endif #if defined(XP_UNIX) -/* GCC 3.3 and later support the visibility attribute. */ -#if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) +/* GCC supports the visibility attribute. */ +#if defined(__GNUC__) #define NP_VISIBILITY_DEFAULT __attribute__((visibility("default"))) #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) #define NP_VISIBILITY_DEFAULT __global diff --git a/dom/plugins/base/nptypes.h b/dom/plugins/base/nptypes.h index d0cef6540..1f8eba3c5 100644 --- a/dom/plugins/base/nptypes.h +++ b/dom/plugins/base/nptypes.h @@ -13,7 +13,7 @@ #if defined(WIN32) /* - * Win32 and OS/2 don't know C99, so define [u]int_16/32/64 here. The bool + * Win32 doesn't know C99, so define [u]int_16/32/64 here. The bool * is predefined tho, both in C and C++. */ typedef short int16_t; @@ -61,28 +61,15 @@ #include #include #endif -#elif defined(BEOS) - #include #else /* * For those that ship a standard C99 stdint.h header file, include - * it. Can't do the same for stdbool.h tho, since some systems ship - * with a stdbool.h file that doesn't compile! + * it. */ #include #ifndef __cplusplus - #if !defined(__GNUC__) || (__GNUC__ > 2 || __GNUC_MINOR__ > 95) - #include - #else - /* - * GCC 2.91 can't deal with a typedef for bool, but a #define - * works. - */ - #define bool int - #define true 1 - #define false 0 - #endif + #include #endif #endif diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 6187b08e0..8b9e25066 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -9843,7 +9843,22 @@ CSSParserImpl::ParseGridLine(nsCSSValue& aValue) // Make the contained value be defined even though we really want a // Nothing here. This works around an otherwise difficult to avoid // Memcheck false positive when this is compiled by gcc-5.3 -O2. - // See bug 1301856. + // The problem is that gcc 5.4 and later, when using high + // optimization, inline Maybe::{isSome,ref} here + // + // if (integer.isSome() && integer.ref() < 0) { + // + // and then proceed to evaluate the expression right-to-left, as if it + // had been written + // + // integer.ref() < 0 && integer.isSome() + // + // This is a legitimate transformation because gcc presumably can prove + // via dataflow analysis that integer.isSome() is false whenever integer.ref() + // is undefined, so the overall expression result is still defined. + // Valgrind/Memcheck assumes that all conditional branches in the program + // are important, and that assumption is deeply wired in, so there is no + // easy way to avoid the warning apart from to force-initialise |integer|. integer.emplace(0); integer.reset(); #endif @@ -15314,17 +15329,17 @@ CSSParserImpl::ParseFontFeatureSettings(nsCSSValue& aValue) return true; } -bool -CSSParserImpl::ParseFontVariationSettings(nsCSSValue& aValue) -{ - // TODO: Actually implement this. - - // This stub is here because websites insist on considering this - // very hardware-dependent and O.S.-variable low-level font-control - // as a "critical feature" which it isn't as there is 0 guarantee - // that font variation settings are supported or honored by any - // operating system used by the client. - return true; +bool +CSSParserImpl::ParseFontVariationSettings(nsCSSValue& aValue) +{ + // TODO: Actually implement this. + + // This stub is here because websites insist on considering this + // very hardware-dependent and O.S.-variable low-level font-control + // as a "critical feature" which it isn't as there is 0 guarantee + // that font variation settings are supported or honored by any + // operating system used by the client. + return true; } bool diff --git a/python/pyyaml/ext/_yaml.c b/python/pyyaml/ext/_yaml.c index f4a5bc524..8a66c0fd3 100644 --- a/python/pyyaml/ext/_yaml.c +++ b/python/pyyaml/ext/_yaml.c @@ -501,14 +501,8 @@ bad: #ifdef __GNUC__ - /* Test for GCC > 2.95 */ - #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) - #define likely(x) __builtin_expect(!!(x), 1) - #define unlikely(x) __builtin_expect(!!(x), 0) - #else /* __GNUC__ > 2 ... */ - #define likely(x) (x) - #define unlikely(x) (x) - #endif /* __GNUC__ > 2 ... */ + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) #else /* __GNUC__ */ #define likely(x) (x) #define unlikely(x) (x) diff --git a/xpcom/base/nscore.h b/xpcom/base/nscore.h index c667a8ae3..6300099ef 100644 --- a/xpcom/base/nscore.h +++ b/xpcom/base/nscore.h @@ -134,18 +134,10 @@ * * where nsIFoo::typeFunc is any method declared as * NS_IMETHOD typeFunc(nsISupports*); - * - * XXX this can be simplified to always use the non-typeof implementation - * when http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11893 is fixed. */ -#ifdef __GNUC__ -#define NS_STDCALL_FUNCPROTO(ret, name, class, func, args) \ - typeof(&class::func) name -#else #define NS_STDCALL_FUNCPROTO(ret, name, class, func, args) \ ret (NS_STDCALL class::*name) args -#endif /** * Deprecated declarations. diff --git a/xpcom/glue/nsCOMPtr.h b/xpcom/glue/nsCOMPtr.h index 7ab6a143c..3b1833c35 100644 --- a/xpcom/glue/nsCOMPtr.h +++ b/xpcom/glue/nsCOMPtr.h @@ -59,10 +59,8 @@ #ifdef __GNUC__ // Our use of nsCOMPtr_base::mRawPtr violates the C++ standard's aliasing - // rules. Mark it with the may_alias attribute so that gcc 3.3 and higher - // don't reorder instructions based on aliasing assumptions for - // this variable. Fortunately, gcc versions < 3.3 do not do any - // optimizations that break nsCOMPtr. + // rules. Mark it with the may_alias attribute so that gcc doesn't reorder + // instructions based on aliasing assumptions for this variable. #define NS_MAY_ALIAS_PTR(t) t* __attribute__((__may_alias__)) #else diff --git a/xpcom/string/nsTSubstring.h b/xpcom/string/nsTSubstring.h index 8e3b41744..a1c126419 100644 --- a/xpcom/string/nsTSubstring.h +++ b/xpcom/string/nsTSubstring.h @@ -991,7 +991,6 @@ protected: friend class nsTObsoleteAStringThunk_CharT; friend class nsTSubstringTuple_CharT; - // XXX GCC 3.4 needs this :-( friend class nsTPromiseFlatString_CharT; char_type* mData; -- cgit v1.2.3 From 904aa57090afbadb92438be951ddd1a2ba17a900 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 2 Mar 2022 18:35:00 +0000 Subject: Issue #15 - part 2: Remove code for implementation of atomics with __sync All supported compilers support using C++11 natively, so implementing this using gcc's old __sync functions is no longer necessary. --- js/src/jit/arm/AtomicOperations-arm.h | 76 --------------- .../jit/mips-shared/AtomicOperations-mips-shared.h | 76 --------------- js/src/jit/none/AtomicOperations-ppc.h | 76 --------------- js/src/jit/none/AtomicOperations-sparc.h | 76 --------------- .../jit/x86-shared/AtomicOperations-x86-shared.h | 108 --------------------- 5 files changed, 412 deletions(-) diff --git a/js/src/jit/arm/AtomicOperations-arm.h b/js/src/jit/arm/AtomicOperations-arm.h index e10b348c0..f9ca690c0 100644 --- a/js/src/jit/arm/AtomicOperations-arm.h +++ b/js/src/jit/arm/AtomicOperations-arm.h @@ -12,18 +12,6 @@ #if defined(__clang__) || defined(__GNUC__) -// The default implementation tactic for gcc/clang is to use the newer -// __atomic intrinsics added for use in C++11 . Where that -// isn't available, we use GCC's older __sync functions instead. -// -// ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS is kept as a backward -// compatible option for older compilers: enable this to use GCC's old -// __sync functions instead of the newer __atomic functions. This -// will be required for GCC 4.6.x and earlier, and probably for Clang -// 3.1, should we need to use those versions. - -//#define ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - inline bool js::jit::AtomicOperations::isLockfree8() { @@ -37,24 +25,16 @@ js::jit::AtomicOperations::isLockfree8() // // For now, make the JIT defer to the C++ compiler when we know what // the C++ compiler will do, otherwise assume a lock is needed. -# ifndef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS MOZ_ASSERT(__atomic_always_lock_free(sizeof(int8_t), 0)); MOZ_ASSERT(__atomic_always_lock_free(sizeof(int16_t), 0)); MOZ_ASSERT(__atomic_always_lock_free(sizeof(int32_t), 0)); return HasLDSTREXBHD() && __atomic_always_lock_free(sizeof(int64_t), 0); -# else - return false; -# endif } inline void js::jit::AtomicOperations::fenceSeqCst() { -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_synchronize(); -# else __atomic_thread_fence(__ATOMIC_SEQ_CST); -# endif } template @@ -62,14 +42,8 @@ inline T js::jit::AtomicOperations::loadSeqCst(T* addr) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_synchronize(); - T v = *addr; - __sync_synchronize(); -# else T v; __atomic_load(addr, &v, __ATOMIC_SEQ_CST); -# endif return v; } @@ -78,13 +52,7 @@ inline void js::jit::AtomicOperations::storeSeqCst(T* addr, T val) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_synchronize(); - *addr = val; - __sync_synchronize(); -# else __atomic_store(addr, &val, __ATOMIC_SEQ_CST); -# endif } template @@ -92,18 +60,9 @@ inline T js::jit::AtomicOperations::exchangeSeqCst(T* addr, T val) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - T v; - __sync_synchronize(); - do { - v = *addr; - } while (__sync_val_compare_and_swap(addr, v, val) != v); - return v; -# else T v; __atomic_exchange(addr, &val, &v, __ATOMIC_SEQ_CST); return v; -# endif } template @@ -111,12 +70,8 @@ inline T js::jit::AtomicOperations::compareExchangeSeqCst(T* addr, T oldval, T newval) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_val_compare_and_swap(addr, oldval, newval); -# else __atomic_compare_exchange(addr, &oldval, &newval, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); return oldval; -# endif } template @@ -124,11 +79,7 @@ inline T js::jit::AtomicOperations::fetchAddSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_add(addr, val); -# else return __atomic_fetch_add(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -136,11 +87,7 @@ inline T js::jit::AtomicOperations::fetchSubSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_sub(addr, val); -# else return __atomic_fetch_sub(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -148,11 +95,7 @@ inline T js::jit::AtomicOperations::fetchAndSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_and(addr, val); -# else return __atomic_fetch_and(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -160,11 +103,7 @@ inline T js::jit::AtomicOperations::fetchOrSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_or(addr, val); -# else return __atomic_fetch_or(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -172,11 +111,7 @@ inline T js::jit::AtomicOperations::fetchXorSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_xor(addr, val); -# else return __atomic_fetch_xor(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -209,17 +144,12 @@ template inline void js::jit::RegionLock::acquire(void* addr) { -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - while (!__sync_bool_compare_and_swap(&spinlock, 0, 1)) - ; -# else uint32_t zero = 0; uint32_t one = 1; while (!__atomic_compare_exchange(&spinlock, &zero, &one, false, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) { zero = 0; continue; } -# endif } template @@ -227,16 +157,10 @@ inline void js::jit::RegionLock::release(void* addr) { MOZ_ASSERT(AtomicOperations::loadSeqCst(&spinlock) == 1, "releasing unlocked region lock"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_sub_and_fetch(&spinlock, 1); -# else uint32_t zero = 0; __atomic_store(&spinlock, &zero, __ATOMIC_SEQ_CST); -# endif } -# undef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - #elif defined(ENABLE_SHARED_ARRAY_BUFFER) # error "Either disable JS shared memory at compile time, use GCC or Clang, or add code here" diff --git a/js/src/jit/mips-shared/AtomicOperations-mips-shared.h b/js/src/jit/mips-shared/AtomicOperations-mips-shared.h index dee930230..7441a27e8 100644 --- a/js/src/jit/mips-shared/AtomicOperations-mips-shared.h +++ b/js/src/jit/mips-shared/AtomicOperations-mips-shared.h @@ -13,22 +13,9 @@ #if defined(__clang__) || defined(__GNUC__) -// The default implementation tactic for gcc/clang is to use the newer -// __atomic intrinsics added for use in C++11 . Where that -// isn't available, we use GCC's older __sync functions instead. -// -// ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS is kept as a backward -// compatible option for older compilers: enable this to use GCC's old -// __sync functions instead of the newer __atomic functions. This -// will be required for GCC 4.6.x and earlier, and probably for Clang -// 3.1, should we need to use those versions. - -//#define ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - inline bool js::jit::AtomicOperations::isLockfree8() { -# ifndef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS MOZ_ASSERT(__atomic_always_lock_free(sizeof(int8_t), 0)); MOZ_ASSERT(__atomic_always_lock_free(sizeof(int16_t), 0)); MOZ_ASSERT(__atomic_always_lock_free(sizeof(int32_t), 0)); @@ -36,19 +23,12 @@ js::jit::AtomicOperations::isLockfree8() MOZ_ASSERT(__atomic_always_lock_free(sizeof(int64_t), 0)); # endif return true; -# else - return false; -# endif } inline void js::jit::AtomicOperations::fenceSeqCst() { -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_synchronize(); -# else __atomic_thread_fence(__ATOMIC_SEQ_CST); -# endif } template @@ -56,14 +36,8 @@ inline T js::jit::AtomicOperations::loadSeqCst(T* addr) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_synchronize(); - T v = *addr; - __sync_synchronize(); -# else T v; __atomic_load(addr, &v, __ATOMIC_SEQ_CST); -# endif return v; } @@ -72,13 +46,7 @@ inline void js::jit::AtomicOperations::storeSeqCst(T* addr, T val) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_synchronize(); - *addr = val; - __sync_synchronize(); -# else __atomic_store(addr, &val, __ATOMIC_SEQ_CST); -# endif } template @@ -86,12 +54,8 @@ inline T js::jit::AtomicOperations::compareExchangeSeqCst(T* addr, T oldval, T newval) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_val_compare_and_swap(addr, oldval, newval); -# else __atomic_compare_exchange(addr, &oldval, &newval, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); return oldval; -# endif } template @@ -99,11 +63,7 @@ inline T js::jit::AtomicOperations::fetchAddSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_add(addr, val); -# else return __atomic_fetch_add(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -111,11 +71,7 @@ inline T js::jit::AtomicOperations::fetchSubSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_sub(addr, val); -# else return __atomic_fetch_sub(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -123,11 +79,7 @@ inline T js::jit::AtomicOperations::fetchAndSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_and(addr, val); -# else return __atomic_fetch_and(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -135,11 +87,7 @@ inline T js::jit::AtomicOperations::fetchOrSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_or(addr, val); -# else return __atomic_fetch_or(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -147,11 +95,7 @@ inline T js::jit::AtomicOperations::fetchXorSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_xor(addr, val); -# else return __atomic_fetch_xor(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -185,35 +129,21 @@ inline T js::jit::AtomicOperations::exchangeSeqCst(T* addr, T val) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - T v; - __sync_synchronize(); - do { - v = *addr; - } while (__sync_val_compare_and_swap(addr, v, val) != v); - return v; -# else T v; __atomic_exchange(addr, &val, &v, __ATOMIC_SEQ_CST); return v; -# endif } template inline void js::jit::RegionLock::acquire(void* addr) { -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - while (!__sync_bool_compare_and_swap(&spinlock, 0, 1)) - ; -# else uint32_t zero = 0; uint32_t one = 1; while (!__atomic_compare_exchange(&spinlock, &zero, &one, false, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) { zero = 0; continue; } -# endif } template @@ -221,16 +151,10 @@ inline void js::jit::RegionLock::release(void* addr) { MOZ_ASSERT(AtomicOperations::loadSeqCst(&spinlock) == 1, "releasing unlocked region lock"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_sub_and_fetch(&spinlock, 1); -# else uint32_t zero = 0; __atomic_store(&spinlock, &zero, __ATOMIC_SEQ_CST); -# endif } -# undef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - #elif defined(ENABLE_SHARED_ARRAY_BUFFER) # error "Either disable JS shared memory at compile time, use GCC or Clang, or add code here" diff --git a/js/src/jit/none/AtomicOperations-ppc.h b/js/src/jit/none/AtomicOperations-ppc.h index 182de9f8a..465c0cf41 100644 --- a/js/src/jit/none/AtomicOperations-ppc.h +++ b/js/src/jit/none/AtomicOperations-ppc.h @@ -13,22 +13,9 @@ #if defined(__clang__) || defined(__GNUC__) -// The default implementation tactic for gcc/clang is to use the newer -// __atomic intrinsics added for use in C++11 . Where that -// isn't available, we use GCC's older __sync functions instead. -// -// ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS is kept as a backward -// compatible option for older compilers: enable this to use GCC's old -// __sync functions instead of the newer __atomic functions. This -// will be required for GCC 4.6.x and earlier, and probably for Clang -// 3.1, should we need to use those versions. - -//#define ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - inline bool js::jit::AtomicOperations::isLockfree8() { -# ifndef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS MOZ_ASSERT(__atomic_always_lock_free(sizeof(int8_t), 0)); MOZ_ASSERT(__atomic_always_lock_free(sizeof(int16_t), 0)); MOZ_ASSERT(__atomic_always_lock_free(sizeof(int32_t), 0)); @@ -37,19 +24,12 @@ js::jit::AtomicOperations::isLockfree8() MOZ_ASSERT(__atomic_always_lock_free(sizeof(int64_t), 0)); # endif return true; -# else - return false; -# endif } inline void js::jit::AtomicOperations::fenceSeqCst() { -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_synchronize(); -# else __atomic_thread_fence(__ATOMIC_SEQ_CST); -# endif } template @@ -57,14 +37,8 @@ inline T js::jit::AtomicOperations::loadSeqCst(T* addr) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_synchronize(); - T v = *addr; - __sync_synchronize(); -# else T v; __atomic_load(addr, &v, __ATOMIC_SEQ_CST); -# endif return v; } @@ -73,13 +47,7 @@ inline void js::jit::AtomicOperations::storeSeqCst(T* addr, T val) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_synchronize(); - *addr = val; - __sync_synchronize(); -# else __atomic_store(addr, &val, __ATOMIC_SEQ_CST); -# endif } template @@ -87,12 +55,8 @@ inline T js::jit::AtomicOperations::compareExchangeSeqCst(T* addr, T oldval, T newval) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_val_compare_and_swap(addr, oldval, newval); -# else __atomic_compare_exchange(addr, &oldval, &newval, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); return oldval; -# endif } template @@ -100,11 +64,7 @@ inline T js::jit::AtomicOperations::fetchAddSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_add(addr, val); -# else return __atomic_fetch_add(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -112,11 +72,7 @@ inline T js::jit::AtomicOperations::fetchSubSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_sub(addr, val); -# else return __atomic_fetch_sub(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -124,11 +80,7 @@ inline T js::jit::AtomicOperations::fetchAndSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_and(addr, val); -# else return __atomic_fetch_and(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -136,11 +88,7 @@ inline T js::jit::AtomicOperations::fetchOrSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_or(addr, val); -# else return __atomic_fetch_or(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -148,11 +96,7 @@ inline T js::jit::AtomicOperations::fetchXorSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_xor(addr, val); -# else return __atomic_fetch_xor(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -186,35 +130,21 @@ inline T js::jit::AtomicOperations::exchangeSeqCst(T* addr, T val) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - T v; - __sync_synchronize(); - do { - v = *addr; - } while (__sync_val_compare_and_swap(addr, v, val) != v); - return v; -# else T v; __atomic_exchange(addr, &val, &v, __ATOMIC_SEQ_CST); return v; -# endif } template inline void js::jit::RegionLock::acquire(void* addr) { -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - while (!__sync_bool_compare_and_swap(&spinlock, 0, 1)) - ; -# else uint32_t zero = 0; uint32_t one = 1; while (!__atomic_compare_exchange(&spinlock, &zero, &one, false, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) { zero = 0; continue; } -# endif } template @@ -222,16 +152,10 @@ inline void js::jit::RegionLock::release(void* addr) { MOZ_ASSERT(AtomicOperations::loadSeqCst(&spinlock) == 1, "releasing unlocked region lock"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_sub_and_fetch(&spinlock, 1); -# else uint32_t zero = 0; __atomic_store(&spinlock, &zero, __ATOMIC_SEQ_CST); -# endif } -# undef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - #elif defined(ENABLE_SHARED_ARRAY_BUFFER) # error "Either disable JS shared memory, use GCC or Clang, or add code here" diff --git a/js/src/jit/none/AtomicOperations-sparc.h b/js/src/jit/none/AtomicOperations-sparc.h index ca689da7e..c962a524e 100644 --- a/js/src/jit/none/AtomicOperations-sparc.h +++ b/js/src/jit/none/AtomicOperations-sparc.h @@ -13,22 +13,9 @@ #if defined(__clang__) || defined(__GNUC__) -// The default implementation tactic for gcc/clang is to use the newer -// __atomic intrinsics added for use in C++11 . Where that -// isn't available, we use GCC's older __sync functions instead. -// -// ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS is kept as a backward -// compatible option for older compilers: enable this to use GCC's old -// __sync functions instead of the newer __atomic functions. This -// will be required for GCC 4.6.x and earlier, and probably for Clang -// 3.1, should we need to use those versions. - -//#define ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - inline bool js::jit::AtomicOperations::isLockfree8() { -# ifndef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS MOZ_ASSERT(__atomic_always_lock_free(sizeof(int8_t), 0)); MOZ_ASSERT(__atomic_always_lock_free(sizeof(int16_t), 0)); MOZ_ASSERT(__atomic_always_lock_free(sizeof(int32_t), 0)); @@ -36,19 +23,12 @@ js::jit::AtomicOperations::isLockfree8() MOZ_ASSERT(__atomic_always_lock_free(sizeof(int64_t), 0)); # endif return true; -# else - return false; -# endif } inline void js::jit::AtomicOperations::fenceSeqCst() { -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_synchronize(); -# else __atomic_thread_fence(__ATOMIC_SEQ_CST); -# endif } template @@ -56,14 +36,8 @@ inline T js::jit::AtomicOperations::loadSeqCst(T* addr) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_synchronize(); - T v = *addr; - __sync_synchronize(); -# else T v; __atomic_load(addr, &v, __ATOMIC_SEQ_CST); -# endif return v; } @@ -72,13 +46,7 @@ inline void js::jit::AtomicOperations::storeSeqCst(T* addr, T val) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_synchronize(); - *addr = val; - __sync_synchronize(); -# else __atomic_store(addr, &val, __ATOMIC_SEQ_CST); -# endif } template @@ -86,12 +54,8 @@ inline T js::jit::AtomicOperations::compareExchangeSeqCst(T* addr, T oldval, T newval) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_val_compare_and_swap(addr, oldval, newval); -# else __atomic_compare_exchange(addr, &oldval, &newval, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); return oldval; -# endif } template @@ -101,11 +65,7 @@ js::jit::AtomicOperations::fetchAddSeqCst(T* addr, T val) #if !defined( __LP64__) static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); #endif -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_add(addr, val); -# else return __atomic_fetch_add(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -115,11 +75,7 @@ js::jit::AtomicOperations::fetchSubSeqCst(T* addr, T val) #if !defined( __LP64__) static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); #endif -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_sub(addr, val); -# else return __atomic_fetch_sub(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -129,11 +85,7 @@ js::jit::AtomicOperations::fetchAndSeqCst(T* addr, T val) #if !defined( __LP64__) static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); #endif -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_and(addr, val); -# else return __atomic_fetch_and(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -143,11 +95,7 @@ js::jit::AtomicOperations::fetchOrSeqCst(T* addr, T val) #if !defined( __LP64__) static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); #endif -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_or(addr, val); -# else return __atomic_fetch_or(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -157,11 +105,7 @@ js::jit::AtomicOperations::fetchXorSeqCst(T* addr, T val) #if !defined( __LP64__) static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); #endif -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_xor(addr, val); -# else return __atomic_fetch_xor(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -195,35 +139,21 @@ inline T js::jit::AtomicOperations::exchangeSeqCst(T* addr, T val) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - T v; - __sync_synchronize(); - do { - v = *addr; - } while (__sync_val_compare_and_swap(addr, v, val) != v); - return v; -# else T v; __atomic_exchange(addr, &val, &v, __ATOMIC_SEQ_CST); return v; -# endif } template inline void js::jit::RegionLock::acquire(void* addr) { -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - while (!__sync_bool_compare_and_swap(&spinlock, 0, 1)) - ; -# else uint32_t zero = 0; uint32_t one = 1; while (!__atomic_compare_exchange(&spinlock, &zero, &one, false, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) { zero = 0; continue; } -# endif } template @@ -231,16 +161,10 @@ inline void js::jit::RegionLock::release(void* addr) { MOZ_ASSERT(AtomicOperations::loadSeqCst(&spinlock) == 1, "releasing unlocked region lock"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_sub_and_fetch(&spinlock, 1); -# else uint32_t zero = 0; __atomic_store(&spinlock, &zero, __ATOMIC_SEQ_CST); -# endif } -# undef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - #elif defined(ENABLE_SHARED_ARRAY_BUFFER) # error "Either disable JS shared memory, use GCC or Clang, or add code here" diff --git a/js/src/jit/x86-shared/AtomicOperations-x86-shared.h b/js/src/jit/x86-shared/AtomicOperations-x86-shared.h index 1230c7feb..4eee00a3d 100644 --- a/js/src/jit/x86-shared/AtomicOperations-x86-shared.h +++ b/js/src/jit/x86-shared/AtomicOperations-x86-shared.h @@ -45,18 +45,6 @@ #if defined(__clang__) || defined(__GNUC__) -// The default implementation tactic for gcc/clang is to use the newer -// __atomic intrinsics added for use in C++11 . Where that -// isn't available, we use GCC's older __sync functions instead. -// -// ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS is kept as a backward -// compatible option for older compilers: enable this to use GCC's old -// __sync functions instead of the newer __atomic functions. This -// will be required for GCC 4.6.x and earlier, and probably for Clang -// 3.1, should we need to use those versions. - -// #define ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - // Lock-free 8-byte atomics are assumed on x86 but must be disabled in // corner cases, see comments below and in isLockfree8(). @@ -77,15 +65,11 @@ inline bool js::jit::AtomicOperations::isLockfree8() { -# ifndef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS MOZ_ASSERT(__atomic_always_lock_free(sizeof(int8_t), 0)); MOZ_ASSERT(__atomic_always_lock_free(sizeof(int16_t), 0)); MOZ_ASSERT(__atomic_always_lock_free(sizeof(int32_t), 0)); -# endif # ifdef LOCKFREE8 -# ifndef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS MOZ_ASSERT(__atomic_always_lock_free(sizeof(int64_t), 0)); -# endif return true; # else return false; @@ -95,11 +79,7 @@ js::jit::AtomicOperations::isLockfree8() inline void js::jit::AtomicOperations::fenceSeqCst() { -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_synchronize(); -# else __atomic_thread_fence(__ATOMIC_SEQ_CST); -# endif } template @@ -107,16 +87,8 @@ inline T js::jit::AtomicOperations::loadSeqCst(T* addr) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - // Inhibit compiler reordering with a volatile load. The x86 does - // not reorder loads with respect to subsequent loads or stores - // and no ordering barrier is required here. See more elaborate - // comments in storeSeqCst. - T v = *static_cast(addr); -# else T v; __atomic_load(addr, &v, __ATOMIC_SEQ_CST); -# endif return v; } @@ -141,43 +113,7 @@ inline void js::jit::AtomicOperations::storeSeqCst(T* addr, T val) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - // Inhibit compiler reordering with a volatile store. The x86 may - // reorder a store with respect to a subsequent load from a - // different location, hence there is an ordering barrier here to - // prevent that. - // - // By way of background, look to eg - // http://bartoszmilewski.com/2008/11/05/who-ordered-memory-fences-on-an-x86/ - // - // Consider: - // - // uint8_t x = 0, y = 0; // to start - // - // thread1: - // sx: AtomicOperations::store(&x, 1); - // gy: uint8_t obs1 = AtomicOperations::loadSeqCst(&y); - // - // thread2: - // sy: AtomicOperations::store(&y, 1); - // gx: uint8_t obs2 = AtomicOperations::loadSeqCst(&x); - // - // Sequential consistency requires a total global ordering of - // operations: sx-gy-sy-gx, sx-sy-gx-gy, sx-sy-gy-gx, sy-gx-sx-gy, - // sy-sx-gy-gx, or sy-sx-gx-gy. In every ordering at least one of - // sx-before-gx or sy-before-gy happens, so *at least one* of - // obs1/obs2 is 1. - // - // If AtomicOperations::{load,store}SeqCst were just volatile - // {load,store}, x86 could reorder gx/gy before each thread's - // prior load. That would permit gx-gy-sx-sy: both loads would be - // 0! Thus after a volatile store we must synchronize to ensure - // the store happens before the load. - *static_cast(addr) = val; - __sync_synchronize(); -# else __atomic_store(addr, &val, __ATOMIC_SEQ_CST); -# endif } # ifndef LOCKFREE8 @@ -201,19 +137,9 @@ inline T js::jit::AtomicOperations::exchangeSeqCst(T* addr, T val) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - T v; - do { - // Here I assume the compiler will not hoist the load. It - // shouldn't, because the CAS could affect* addr. - v = *addr; - } while (!__sync_bool_compare_and_swap(addr, v, val)); - return v; -# else T v; __atomic_exchange(addr, &val, &v, __ATOMIC_SEQ_CST); return v; -# endif } # ifndef LOCKFREE8 @@ -237,12 +163,8 @@ inline T js::jit::AtomicOperations::compareExchangeSeqCst(T* addr, T oldval, T newval) { MOZ_ASSERT(sizeof(T) < 8 || isLockfree8()); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_val_compare_and_swap(addr, oldval, newval); -# else __atomic_compare_exchange(addr, &oldval, &newval, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); return oldval; -# endif } # ifndef LOCKFREE8 @@ -266,11 +188,7 @@ inline T js::jit::AtomicOperations::fetchAddSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_add(addr, val); -# else return __atomic_fetch_add(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -278,11 +196,7 @@ inline T js::jit::AtomicOperations::fetchSubSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_sub(addr, val); -# else return __atomic_fetch_sub(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -290,11 +204,7 @@ inline T js::jit::AtomicOperations::fetchAndSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_and(addr, val); -# else return __atomic_fetch_and(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -302,11 +212,7 @@ inline T js::jit::AtomicOperations::fetchOrSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_or(addr, val); -# else return __atomic_fetch_or(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -314,11 +220,7 @@ inline T js::jit::AtomicOperations::fetchXorSeqCst(T* addr, T val) { static_assert(sizeof(T) <= 4, "not available for 8-byte values yet"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - return __sync_fetch_and_xor(addr, val); -# else return __atomic_fetch_xor(addr, val, __ATOMIC_SEQ_CST); -# endif } template @@ -351,17 +253,12 @@ template inline void js::jit::RegionLock::acquire(void* addr) { -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - while (!__sync_bool_compare_and_swap(&spinlock, 0, 1)) - continue; -# else uint32_t zero = 0; uint32_t one = 1; while (!__atomic_compare_exchange(&spinlock, &zero, &one, false, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) { zero = 0; continue; } -# endif } template @@ -369,15 +266,10 @@ inline void js::jit::RegionLock::release(void* addr) { MOZ_ASSERT(AtomicOperations::loadSeqCst(&spinlock) == 1, "releasing unlocked region lock"); -# ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS - __sync_sub_and_fetch(&spinlock, 1); // Should turn into LOCK XADD -# else uint32_t zero = 0; __atomic_store(&spinlock, &zero, __ATOMIC_SEQ_CST); -# endif } -# undef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS # undef LOCKFREE8 #elif defined(_MSC_VER) -- cgit v1.2.3 From 872bfa373ddfc184e17caf1ba38dbb02ed9c37f0 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 2 Mar 2022 20:07:06 +0000 Subject: Issue #15 - Part 3: Remove more old gcc compiler hacks. --- js/src/gc/Heap.h | 4 +--- js/src/jit/Safepoints.cpp | 6 +----- js/src/jit/arm/Architecture-arm.h | 3 +-- js/src/jit/arm/Simulator-arm.cpp | 2 -- js/src/jit/arm64/vixl/Assembler-vixl.h | 4 +--- js/src/jit/arm64/vixl/MozAssembler-vixl.cpp | 2 +- js/src/wasm/WasmBaselineCompile.cpp | 4 ++-- 7 files changed, 7 insertions(+), 18 deletions(-) diff --git a/js/src/gc/Heap.h b/js/src/gc/Heap.h index 2f2770260..2a1042094 100644 --- a/js/src/gc/Heap.h +++ b/js/src/gc/Heap.h @@ -80,9 +80,7 @@ enum InitialHeap { }; /* The GC allocation kinds. */ -// FIXME: uint8_t would make more sense for the underlying type, but causes -// miscompilations in GCC (fixed in 4.8.5 and 4.9.3). See also bug 1143966. -enum class AllocKind { +enum class AllocKind : uint8_t { FIRST, OBJECT_FIRST = FIRST, FUNCTION = FIRST, diff --git a/js/src/jit/Safepoints.cpp b/js/src/jit/Safepoints.cpp index 9446861a0..27cb64254 100644 --- a/js/src/jit/Safepoints.cpp +++ b/js/src/jit/Safepoints.cpp @@ -264,11 +264,7 @@ AllocationToPartKind(const LAllocation& a) return Part_Arg; } -// gcc 4.5 doesn't actually inline CanEncodeInfoInHeader when only -// using the "inline" keyword, and miscompiles the function as well -// when doing block reordering with branch prediction information. -// See bug 799295 comment 71. -static MOZ_ALWAYS_INLINE bool +static inline bool CanEncodeInfoInHeader(const LAllocation& a, uint32_t* out) { if (a.isGeneralReg()) { diff --git a/js/src/jit/arm/Architecture-arm.h b/js/src/jit/arm/Architecture-arm.h index d2c634798..5dbc68a59 100644 --- a/js/src/jit/arm/Architecture-arm.h +++ b/js/src/jit/arm/Architecture-arm.h @@ -13,8 +13,7 @@ #include "js/Utility.h" -// GCC versions 4.6 and above define __ARM_PCS_VFP to denote a hard-float -// ABI target. +// GCC defines __ARM_PCS_VFP to denote a hard-float ABI target. #if defined(__ARM_PCS_VFP) #define JS_CODEGEN_ARM_HARDFP #endif diff --git a/js/src/jit/arm/Simulator-arm.cpp b/js/src/jit/arm/Simulator-arm.cpp index 2b295212a..5dfdb939a 100644 --- a/js/src/jit/arm/Simulator-arm.cpp +++ b/js/src/jit/arm/Simulator-arm.cpp @@ -1289,8 +1289,6 @@ int32_t Simulator::get_register(int reg) const { MOZ_ASSERT(reg >= 0 && reg < num_registers); - // Work around GCC bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949 - if (reg >= num_registers) return 0; return registers_[reg] + ((reg == pc) ? SimInstruction::kPCReadOffset : 0); } diff --git a/js/src/jit/arm64/vixl/Assembler-vixl.h b/js/src/jit/arm64/vixl/Assembler-vixl.h index d209f8b57..175349bf5 100644 --- a/js/src/jit/arm64/vixl/Assembler-vixl.h +++ b/js/src/jit/arm64/vixl/Assembler-vixl.h @@ -4016,11 +4016,9 @@ class Assembler : public MozBaseAssembler { const MemOperand& addr, LoadStoreScalingOption option = PreferScaledOffset); - // TODO(all): The third parameter should be passed by reference but gcc 4.8.2 - // reports a bogus uninitialised warning then. BufferOffset Logical(const Register& rd, const Register& rn, - const Operand operand, + const Operand& operand, LogicalOp op); BufferOffset LogicalImmediate(const Register& rd, const Register& rn, diff --git a/js/src/jit/arm64/vixl/MozAssembler-vixl.cpp b/js/src/jit/arm64/vixl/MozAssembler-vixl.cpp index 3b2e0a8bc..a9bb8a18d 100644 --- a/js/src/jit/arm64/vixl/MozAssembler-vixl.cpp +++ b/js/src/jit/arm64/vixl/MozAssembler-vixl.cpp @@ -400,7 +400,7 @@ void Assembler::nop(Instruction* at) { BufferOffset Assembler::Logical(const Register& rd, const Register& rn, - const Operand operand, LogicalOp op) + const Operand& operand, LogicalOp op) { VIXL_ASSERT(rd.size() == rn.size()); if (operand.IsImmediate()) { diff --git a/js/src/wasm/WasmBaselineCompile.cpp b/js/src/wasm/WasmBaselineCompile.cpp index d4849f3d1..7a905ecbe 100644 --- a/js/src/wasm/WasmBaselineCompile.cpp +++ b/js/src/wasm/WasmBaselineCompile.cpp @@ -387,9 +387,9 @@ class BaseCompiler #endif case NONE: MOZ_CRASH("AnyReg::any() on NONE"); + default: + return AnyRegister(); } - // Work around GCC 5 analysis/warning bug. - MOZ_CRASH("AnyReg::any(): impossible case"); } union { -- cgit v1.2.3