Bug 1445105 - Remove various MSVC de-optimizations used to work around compiler bugs which are no longer needed. r=dmajor
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 19 Mar 2018 12:42:01 -0400
changeset 408793 34a7d2c7e73e01dd81323c90348a98bd37e259f7
parent 408792 f730e59ed70405c6040684208666c9245df7dbc4
child 408794 58ddcf890331b9ddbc81b9bf4e8e3e04f551996e
push id101051
push userryanvm@gmail.com
push dateMon, 19 Mar 2018 16:53:17 +0000
treeherdermozilla-inbound@34a7d2c7e73e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdmajor
bugs1445105, 703135, 977538, 1274450, 1403220
milestone61.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 1445105 - Remove various MSVC de-optimizations used to work around compiler bugs which are no longer needed. r=dmajor This reverts the following bugs: 703135, 977538, 1274450, 1403220
js/public/Value.h
layout/generic/nsTextFrame.cpp
layout/xul/tree/nsTreeBodyFrame.cpp
media/libtheora/bug703135.patch
media/libtheora/lib/huffdec.c
media/libtheora/update.sh
--- a/js/public/Value.h
+++ b/js/public/Value.h
@@ -260,30 +260,23 @@ constexpr uint64_t CanonicalizedNaNBits 
  */
 static MOZ_ALWAYS_INLINE double
 GenericNaN()
 {
   return mozilla::SpecificNaN<double>(detail::CanonicalizedNaNSignBit,
                                       detail::CanonicalizedNaNSignificand);
 }
 
-/* MSVC with PGO miscompiles this function. */
-#if defined(_MSC_VER)
-# pragma optimize("g", off)
-#endif
 static inline double
 CanonicalizeNaN(double d)
 {
     if (MOZ_UNLIKELY(mozilla::IsNaN(d)))
         return GenericNaN();
     return d;
 }
-#if defined(_MSC_VER)
-# pragma optimize("", on)
-#endif
 
 /**
  * JS::Value is the interface for a single JavaScript Engine value.  A few
  * general notes on JS::Value:
  *
  * - JS::Value has setX() and isX() members for X in
  *
  *     { Int32, Double, String, Symbol, Boolean, Undefined, Null, Object, Magic }
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -2002,20 +2002,16 @@ BuildTextRunsScanner::GetNextBreakBefore
 {
   uint32_t index = *aIndex;
   if (index >= mLineBreakBeforeFrames.Length())
     return nullptr;
   *aIndex = index + 1;
   return static_cast<nsTextFrame*>(mLineBreakBeforeFrames.ElementAt(index));
 }
 
-// Bug 1403220: Suspected MSVC PGO miscompilation
-#if defined(_MSC_VER) && defined(_M_IX86)
-#pragma optimize("", off)
-#endif
 static gfxFontGroup*
 GetFontGroupForFrame(const nsIFrame* aFrame, float aFontSizeInflation,
                      nsFontMetrics** aOutFontMetrics = nullptr)
 {
   RefPtr<nsFontMetrics> metrics =
     nsLayoutUtils::GetFontMetricsForFrame(aFrame, aFontSizeInflation);
   gfxFontGroup* fontGroup = metrics->GetThebesFontGroup();
 
@@ -2024,19 +2020,16 @@ GetFontGroupForFrame(const nsIFrame* aFr
     metrics.forget(aOutFontMetrics);
   }
   // XXX this is a bit bogus, we're releasing 'metrics' so the
   // returned font-group might actually be torn down, although because
   // of the way the device context caches font metrics, this seems to
   // not actually happen. But we should fix this.
   return fontGroup;
 }
-#if defined(_MSC_VER) && defined(_M_IX86)
-#pragma optimize("", on)
-#endif
 
 static already_AddRefed<DrawTarget>
 CreateReferenceDrawTarget(const nsTextFrame* aTextFrame)
 {
   RefPtr<gfxContext> ctx =
     aTextFrame->PresShell()->CreateReferenceRenderingContext();
   RefPtr<DrawTarget> dt = ctx->GetDrawTarget();
   return dt.forget();
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -3688,23 +3688,16 @@ nsTreeBodyFrame::PaintImage(int32_t     
   aRemainingWidth -= imageRect.width;
   if (!isRTL) {
     aCurrX += imageRect.width;
   }
 
   return result;
 }
 
-// Disable PGO for PaintText because MSVC 2015 seems to have decided
-// that it can null out the alreadyAddRefed<nsFontMetrics> used to
-// initialize fontMet after storing fontMet on the stack in the same
-// space, overwriting fontMet's stack storage with null.
-#ifdef _MSC_VER
-# pragma optimize("g", off)
-#endif
 ImgDrawResult
 nsTreeBodyFrame::PaintText(int32_t              aRowIndex,
                            nsTreeColumn*        aColumn,
                            const nsRect&        aTextRect,
                            nsPresContext*      aPresContext,
                            gfxContext&          aRenderingContext,
                            const nsRect&        aDirtyRect,
                            nscoord&             aCurrX)
@@ -3826,19 +3819,16 @@ nsTreeBodyFrame::PaintText(int32_t      
                             cellContext);
 
   if (opacity != 1.0f) {
     aRenderingContext.PopGroupAndBlend();
   }
 
   return result;
 }
-#ifdef _MSC_VER
-# pragma optimize("", on)
-#endif
 
 ImgDrawResult
 nsTreeBodyFrame::PaintCheckbox(int32_t              aRowIndex,
                                nsTreeColumn*        aColumn,
                                const nsRect&        aCheckboxRect,
                                nsPresContext*      aPresContext,
                                gfxContext&          aRenderingContext,
                                const nsRect&        aDirtyRect)
deleted file mode 100644
--- a/media/libtheora/bug703135.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-diff --git a/media/libtheora/lib/huffdec.c b/media/libtheora/lib/huffdec.c
---- a/media/libtheora/lib/huffdec.c
-+++ b/media/libtheora/lib/huffdec.c
-@@ -320,16 +320,19 @@ static size_t oc_huff_node_size(int _nbi
- /*Produces a collapsed-tree representation of the given token list.
-   _tree: The storage for the collapsed Huffman tree.
-          This may be NULL to compute the required storage size instead of
-           constructing the tree.
-   _tokens:  A list of internal tokens, in the order they are found in the
-              codebook, and the lengths of their corresponding codewords.
-   _ntokens: The number of tokens corresponding to this tree node.
-   Return: The number of words required to store the tree.*/
-+#if defined(_MSC_VER) && _MSC_VER >= 1700
-+#pragma optimize( "", off )
-+#endif
- static size_t oc_huff_tree_collapse(ogg_int16_t *_tree,
-  unsigned char _tokens[][2],int _ntokens){
-   ogg_int16_t   node[34];
-   unsigned char depth[34];
-   unsigned char last[34];
-   size_t        ntree;
-   int           ti;
-   int           l;
-@@ -367,16 +370,19 @@ static size_t oc_huff_tree_collapse(ogg_
-       /*Pop back up a level of recursion.*/
-       else if(l-->0)nbits=depth[l+1]-depth[l];
-     }
-     while(l>=0);
-   }
-   while(l>=0);
-   return ntree;
- }
-+#if defined(_MSC_VER) && _MSC_VER >= 1700
-+#pragma optimize( "", on )
-+#endif
- 
- /*Unpacks a set of Huffman trees, and reduces them to a collapsed
-    representation.
-   _opb:   The buffer to unpack the trees from.
-   _nodes: The table to fill with the Huffman trees.
-   Return: 0 on success, or a negative value on error.
-           The caller is responsible for cleaning up any partially initialized
-            _nodes on failure.*/
--- a/media/libtheora/lib/huffdec.c
+++ b/media/libtheora/lib/huffdec.c
@@ -320,19 +320,16 @@ static size_t oc_huff_node_size(int _nbi
 /*Produces a collapsed-tree representation of the given token list.
   _tree: The storage for the collapsed Huffman tree.
          This may be NULL to compute the required storage size instead of
           constructing the tree.
   _tokens:  A list of internal tokens, in the order they are found in the
              codebook, and the lengths of their corresponding codewords.
   _ntokens: The number of tokens corresponding to this tree node.
   Return: The number of words required to store the tree.*/
-#if defined(_MSC_VER) && _MSC_VER >= 1700
-#pragma optimize( "", off )
-#endif
 static size_t oc_huff_tree_collapse(ogg_int16_t *_tree,
  unsigned char _tokens[][2],int _ntokens){
   ogg_int16_t   node[34];
   unsigned char depth[34];
   unsigned char last[34];
   size_t        ntree;
   int           ti;
   int           l;
@@ -370,19 +367,16 @@ static size_t oc_huff_tree_collapse(ogg_
       /*Pop back up a level of recursion.*/
       else if(l-->0)nbits=depth[l+1]-depth[l];
     }
     while(l>=0);
   }
   while(l>=0);
   return ntree;
 }
-#if defined(_MSC_VER) && _MSC_VER >= 1700
-#pragma optimize( "", on )
-#endif
 
 /*Unpacks a set of Huffman trees, and reduces them to a collapsed
    representation.
   _opb:   The buffer to unpack the trees from.
   _nodes: The table to fill with the Huffman trees.
   Return: 0 on success, or a negative value on error.
           The caller is responsible for cleaning up any partially initialized
            _nodes on failure.*/
--- a/media/libtheora/update.sh
+++ b/media/libtheora/update.sh
@@ -77,10 +77,9 @@ cp $1/lib/x86_vc/x86state.c ./lib/x86_vc
 cp $1/include/theora/theora.h ./include/theora/theora.h
 cp $1/include/theora/theoradec.h ./include/theora/theoradec.h
 cp $1/include/theora/theoraenc.h ./include/theora/theoraenc.h
 cp $1/include/theora/codec.h ./include/theora/codec.h
 patch -p3 < ./bug625773-r17780.patch
 patch -p3 < ./bug468275-r18219.patch
 patch -p3 < ./bug752139-r18031.patch
 patch -p3 < ./bug752668-r18268.patch
-patch -p3 < ./bug703135.patch
 patch -p3 < ./bug920992.patch