Bug 1146902 - be smarter about inlining atomics. r=jandem
authorLars T Hansen <lhansen@mozilla.com>
Fri, 27 Mar 2015 12:38:36 +0100
changeset 266416 bcd5980d0ec3d20389c49f3935795502497b27bd
parent 266415 b1f9fa1917187b8303f7cef6a27ab6aa1496372f
child 266417 8c45833b771aff8f8338e423af21ab03420799da
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1146902
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1146902 - be smarter about inlining atomics. r=jandem
js/src/jit/Ion.cpp
js/src/jit/Ion.h
js/src/jit/MCallOptimize.cpp
--- a/js/src/jit/Ion.cpp
+++ b/js/src/jit/Ion.cpp
@@ -3054,12 +3054,26 @@ jit::JitSupportsFloatingPoint()
 }
 
 bool
 jit::JitSupportsSimd()
 {
     return js::jit::MacroAssembler::SupportsSimd();
 }
 
+bool
+jit::JitSupportsAtomics()
+{
+#if defined(JS_CODEGEN_ARM)
+    // Bug 1146902, bug 1077318: Enable Ion inlining of Atomics
+    // operations on ARM only when the CPU has byte, halfword, and
+    // doubleword load-exclusive and store-exclusive instructions,
+    // until we can add support for systems that don't have those.
+    return js::jit::HasLDSTREXBHD();
+#else
+    return true;
+#endif
+}
+
 // If you change these, please also change the comment in TempAllocator.
 /* static */ const size_t TempAllocator::BallastSize            = 16 * 1024;
 /* static */ const size_t TempAllocator::PreferredLifoChunkSize = 32 * 1024;
 
--- a/js/src/jit/Ion.h
+++ b/js/src/jit/Ion.h
@@ -196,13 +196,14 @@ void ForbidCompilation(JSContext *cx, JS
 
 void PurgeCaches(JSScript *script);
 size_t SizeOfIonData(JSScript *script, mozilla::MallocSizeOf mallocSizeOf);
 void DestroyJitScripts(FreeOp *fop, JSScript *script);
 void TraceJitScripts(JSTracer* trc, JSScript *script);
 
 bool JitSupportsFloatingPoint();
 bool JitSupportsSimd();
+bool JitSupportsAtomics();
 
 } // namespace jit
 } // namespace js
 
 #endif /* jit_Ion_h */
--- a/js/src/jit/MCallOptimize.cpp
+++ b/js/src/jit/MCallOptimize.cpp
@@ -2824,16 +2824,19 @@ IonBuilder::inlineAtomicsStore(CallInfo 
 IonBuilder::InliningStatus
 IonBuilder::inlineAtomicsFence(CallInfo &callInfo)
 {
     if (callInfo.argc() != 0 || callInfo.constructing()) {
         trackOptimizationOutcome(TrackedOutcome::CantInlineNativeBadForm);
         return InliningStatus_NotInlined;
     }
 
+    if (!JitSupportsAtomics())
+        return InliningStatus_NotInlined;
+
     callInfo.setImplicitlyUsedUnchecked();
 
     MMemoryBarrier *fence = MMemoryBarrier::New(alloc());
     current->add(fence);
     pushConstant(UndefinedValue());
 
     // Fences are considered effectful (they execute a memory barrier).
     if (!resumeAfter(fence))
@@ -2894,16 +2897,19 @@ IonBuilder::inlineAtomicsBinop(CallInfo 
         return InliningStatus_Error;
 
     return InliningStatus_Inlined;
 }
 
 bool
 IonBuilder::atomicsMeetsPreconditions(CallInfo &callInfo, Scalar::Type *arrayType)
 {
+    if (!JitSupportsAtomics())
+        return false;
+
     if (callInfo.getArg(0)->type() != MIRType_Object)
         return false;
 
     if (callInfo.getArg(1)->type() != MIRType_Int32)
         return false;
 
     // Ensure that the first argument is a valid SharedTypedArray.
     //