diff --git a/js/xpconnect/src/XPCWrappedNative.cpp b/js/xpconnect/src/XPCWrappedNative.cpp
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -1216,29 +1216,37 @@ public:
     }
 
     ~CallMethodHelper();
 
     MOZ_ALWAYS_INLINE bool Call();
 
 };
 
+#ifdef _MSC_VER
+#pragma optimize("g", off)
+#endif
+
 // static
 bool
 XPCWrappedNative::CallMethod(XPCCallContext& ccx,
                              CallMode mode /*= CALL_METHOD */)
 {
     nsresult rv = ccx.CanCallNow();
     if (NS_FAILED(rv)) {
         return Throw(rv, ccx);
     }
 
     return CallMethodHelper(ccx).Call();
 }
 
+#ifdef _MSC_VER
+#pragma optimize("", on)
+#endif
+
 bool
 CallMethodHelper::Call()
 {
     mCallContext.SetRetVal(JS::UndefinedValue());
 
     mCallContext.GetContext()->SetPendingException(nullptr);
 
     if (mVTableIndex == 0) {
