Turn PGO off for various functions (bug 791214, r=jandem).
authorDavid Anderson <danderson@mozilla.com>
Fri, 07 Dec 2012 14:01:40 -0800
changeset 115356 aeba5e501a21
parent 115355 957f94452cd5
child 115357 18e7c87def37
push id19306
push userdanderson@mozilla.com
push dateFri, 07 Dec 2012 22:03:22 +0000
treeherdermozilla-inbound@aeba5e501a21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs791214
milestone20.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
Turn PGO off for various functions (bug 791214, r=jandem).
js/src/jsmath.cpp
js/src/jsnum.cpp
js/src/methodjit/MonoIC.cpp
--- a/js/src/jsmath.cpp
+++ b/js/src/jsmath.cpp
@@ -412,16 +412,20 @@ js_math_min(JSContext *cx, unsigned argc
         } else {
             z = (x < z) ? x : z;
         }
     }
     vp->setNumber(z);
     return JS_TRUE;
 }
 
+// Disable PGO for Math.pow() and related functions (see bug 791214).
+#if defined(_MSC_VER)
+# pragma optimize("g", off)
+#endif
 double
 js::powi(double x, int y)
 {
     unsigned n = (y < 0) ? -y : y;
     double m = x;
     double p = 1;
     while (true) {
         if ((n & 1) != 0) p *= m;
@@ -439,29 +443,43 @@ js::powi(double x, int y)
                        : result;
             }
 
             return p;
         }
         m *= m;
     }
 }
+#if defined(_MSC_VER)
+# pragma optimize("", on)
+#endif
 
+// Disable PGO for Math.pow() and related functions (see bug 791214).
+#if defined(_MSC_VER)
+# pragma optimize("g", off)
+#endif
 double
 js::ecmaPow(double x, double y)
 {
     /*
      * Because C99 and ECMA specify different behavior for pow(),
      * we need to wrap the libm call to make it ECMA compliant.
      */
     if (!MOZ_DOUBLE_IS_FINITE(y) && (x == 1.0 || x == -1.0))
         return js_NaN;
     return pow(x, y);
 }
+#if defined(_MSC_VER)
+# pragma optimize("", on)
+#endif
 
+// Disable PGO for Math.pow() and related functions (see bug 791214).
+#if defined(_MSC_VER)
+# pragma optimize("g", off)
+#endif
 JSBool
 js_math_pow(JSContext *cx, unsigned argc, Value *vp)
 {
     double x, y, z;
 
     if (argc <= 1) {
         vp->setDouble(js_NaN);
         return JS_TRUE;
@@ -496,16 +514,19 @@ js_math_pow(JSContext *cx, unsigned argc
     if (int32_t(y) == y)
         z = powi(x, int32_t(y));
     else
         z = ecmaPow(x, y);
 
     vp->setNumber(z);
     return JS_TRUE;
 }
+#if defined(_MSC_VER)
+# pragma optimize("", on)
+#endif
 
 static const int64_t RNG_MULTIPLIER = 0x5DEECE66DLL;
 static const int64_t RNG_ADDEND = 0xBLL;
 static const int64_t RNG_MASK = (1LL << 48) - 1;
 static const double RNG_DSCALE = double(1LL << 53);
 
 /*
  * Math.random() support, lifted from java.util.Random.java.
--- a/js/src/jsnum.cpp
+++ b/js/src/jsnum.cpp
@@ -1324,16 +1324,19 @@ js::NumberValueToStringBuffer(JSContext 
      * Inflate to jschar string.  The input C-string characters are < 127, so
      * even if jschars are UTF-8, all chars should map to one jschar.
      */
     size_t cstrlen = strlen(cstr);
     JS_ASSERT(!cbuf.dbuf && cstrlen < cbuf.sbufSize);
     return sb.appendInflated(cstr, cstrlen);
 }
 
+#if defined(_MSC_VER)
+# pragma optimize("g", off)
+#endif
 JS_PUBLIC_API(bool)
 js::ToNumberSlow(JSContext *cx, Value v, double *out)
 {
     AssertCanGC();
 #ifdef DEBUG
     /*
      * MSVC bizarrely miscompiles this, complaining about the first brace below
      * being unmatched (!).  The error message points at both this opening brace
@@ -1382,16 +1385,19 @@ js::ToNumberSlow(JSContext *cx, Value v,
             return false;
         if (v.isObject())
             break;
     }
 
     *out = js_NaN;
     return true;
 }
+#if defined(_MSC_VER)
+# pragma optimize("", on)
+#endif
 
 /*
  * Convert a value to an int64_t, according to the WebIDL rules for long long
  * conversion. Return converted value in *out on success, false on failure.
  */
 JS_PUBLIC_API(bool)
 js::ToInt64Slow(JSContext *cx, const Value &v, int64_t *out)
 {
--- a/js/src/methodjit/MonoIC.cpp
+++ b/js/src/methodjit/MonoIC.cpp
@@ -374,16 +374,21 @@ ic::Equality(VMFrame &f, ic::EqualityICI
 {
     EqualityCompiler cc(f, *ic);
     if (!cc.update())
         THROWV(JS_FALSE);
 
     return ic->stub(f);
 }
 
+// Disable PGO as a precaution (see bug 791214).
+#if defined(_MSC_VER)
+# pragma optimize("g", off)
+#endif
+
 static void * JS_FASTCALL
 SlowCallFromIC(VMFrame &f, ic::CallICInfo *ic)
 {
     stubs::SlowCall(f, ic->frameSize.getArgc(f));
     return NULL;
 }
 
 static void * JS_FASTCALL
@@ -1418,16 +1423,20 @@ ic::SplatApplyArgs(VMFrame &f)
     /* Steps 7-8. */
     if (!GetElements(cx, aobj, length, f.regs.sp - length))
         THROWV(false);
 
     f.u.call.dynamicArgc = length;
     return true;
 }
 
+#if defined(_MSC_VER)
+# pragma optimize("", on)
+#endif
+
 void
 ic::GenerateArgumentCheckStub(VMFrame &f)
 {
     AutoAssertNoGC nogc;
     JS_ASSERT(f.cx->typeInferenceEnabled());
 
     JITScript *jit = f.jit();
     StackFrame *fp = f.fp();