Bug 1342176: Enable 80-bits precision for the x87 floating-point unit; r=jandem
authorBenjamin Bouvier <benj@benj.me>
Thu, 23 Feb 2017 20:03:46 +0100
changeset 374090 06254f3037c370bfa81a26c4a5ff673c8e16940f
parent 374089 7a9b07064c28ac88d837c14e3cc85e95a8597aa9
child 374091 1ad2304b97a8391de83cf681bbd2a0554eac7cfb
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1342176
milestone54.0a1
Bug 1342176: Enable 80-bits precision for the x87 floating-point unit; r=jandem MozReview-Commit-ID: 1Y4H0ywIX5Q
js/src/jsnum.cpp
js/src/jsnum.h
js/src/vm/HelperThreads.cpp
--- a/js/src/jsnum.cpp
+++ b/js/src/jsnum.cpp
@@ -1125,38 +1125,19 @@ static const JSFunctionSpec number_stati
     JS_SELF_HOSTED_FN("isFinite", "Number_isFinite", 1,0),
     JS_FN("isInteger", Number_isInteger, 1, 0),
     JS_SELF_HOSTED_FN("isNaN", "Number_isNaN", 1,0),
     JS_SELF_HOSTED_FN("isSafeInteger", "Number_isSafeInteger", 1,0),
     JS_FS_END
 };
 
 
-/*
- * Set the exception mask to mask all exceptions and set the FPU precision
- * to 53 bit mantissa (64 bit doubles).
- */
-void
-js::FIX_FPU()
-{
-#if (defined __GNUC__ && defined __i386__) || \
-    (defined __SUNPRO_CC && defined __i386)
-    short control;
-    asm("fstcw %0" : "=m" (control) : );
-    control &= ~0x300; // Lower bits 8 and 9 (precision control).
-    control |= 0x2f3;  // Raise bits 0-5 (exception masks) and 9 (64-bit precision).
-    asm("fldcw %0" : : "m" (control) );
-#endif
-}
-
 bool
 js::InitRuntimeNumberState(JSRuntime* rt)
 {
-    FIX_FPU();
-
     // XXX If EXPOSE_INTL_API becomes true all the time at some point,
     //     js::InitRuntimeNumberState is no longer fallible, and we should
     //     change its return type.
 #if !EXPOSE_INTL_API
     /* Copy locale-specific separators into the runtime strings. */
     const char* thousandsSeparator;
     const char* decimalPoint;
     const char* grouping;
@@ -1218,19 +1199,16 @@ js::FinishRuntimeNumberState(JSRuntime* 
 }
 #endif
 
 JSObject*
 js::InitNumberClass(JSContext* cx, HandleObject obj)
 {
     MOZ_ASSERT(obj->isNative());
 
-    /* XXX must do at least once per new thread, so do it per JSContext... */
-    FIX_FPU();
-
     Handle<GlobalObject*> global = obj.as<GlobalObject>();
 
     RootedObject numberProto(cx, GlobalObject::createBlankPrototype(cx, global,
                                                                     &NumberObject::class_));
     if (!numberProto)
         return nullptr;
     numberProto->as<NumberObject>().setPrimitiveValue(0);
 
--- a/js/src/jsnum.h
+++ b/js/src/jsnum.h
@@ -335,13 +335,11 @@ SafeMul(int32_t one, int32_t two, int32_
     return !__builtin_smul_overflow(one, two, res);
 #else
     *res = uint32_t(one) * uint32_t(two);
     int64_t ores = (int64_t)one * (int64_t)two;
     return ores == (int64_t)*res;
 #endif
 }
 
-void FIX_FPU();
-
 } /* namespace js */
 
 #endif /* jsnum_h */
--- a/js/src/vm/HelperThreads.cpp
+++ b/js/src/vm/HelperThreads.cpp
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "vm/HelperThreads.h"
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Unused.h"
 
 #include "jsnativestack.h"
-#include "jsnum.h" // For FIX_FPU()
 
 #include "builtin/Promise.h"
 #include "frontend/BytecodeCompiler.h"
 #include "gc/GCInternals.h"
 #include "jit/IonBuilder.h"
 #include "threading/CpuCount.h"
 #include "vm/Debugger.h"
 #include "vm/SharedImmutableStringsCache.h"
@@ -1444,22 +1443,16 @@ HelperThread::destroy()
 }
 
 /* static */
 void
 HelperThread::ThreadMain(void* arg)
 {
     ThisThread::SetName("JS Helper");
 
-    //See bug 1104658.
-    //Set the FPU control word to be the same as the active thread's, or math
-    //computations on this thread may use incorrect precision rules during
-    //Ion compilation.
-    FIX_FPU();
-
     static_cast<HelperThread*>(arg)->threadLoop();
     Mutex::ShutDown();
 }
 
 void
 HelperThread::handleWasmWorkload(AutoLockHelperThreadState& locked)
 {
     MOZ_ASSERT(HelperThreadState().canStartWasmCompile(locked));