Bug 791214 - Turn PGO off for various functions. r=jandem, a=akeybl
authorDavid Anderson <danderson@mozilla.com>
Fri, 07 Dec 2012 14:01:40 -0800
changeset 118724 d0ba3d9c94f4
parent 118723 c77a793b8449
child 118725 1025cf210e7a
push id2909
push userryanvm@gmail.com
push date2012-12-10 17:21 +0000
treeherdermozilla-aurora@1025cf210e7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem, akeybl
bugs791214
milestone19.0a2
Bug 791214 - Turn PGO off for various functions. r=jandem, a=akeybl
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
@@ -1338,16 +1338,19 @@ NumberValueToStringBuffer(JSContext *cx,
      * 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)
 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
@@ -1396,16 +1399,19 @@ ToNumberSlow(JSContext *cx, Value v, dou
             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)
 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();