Bug 1403220 - De-optimize the GetFontGroupForFrame function on Win32 to work around an MSVC PGO crash. r+a=RyanVM
authorDavid Major <dmajor@mozilla.com>
Thu, 28 Sep 2017 13:27:01 -0400
changeset 432010 bd13ea56e690c84920e5f548e0a171e0966c152f
parent 432009 1c9c05f5e5bd073187b2d16e0f87438bd730d2a2
child 432011 c048148b2f2d6ea31c20d9068947bbb7945348bf
push id7870
push userryanvm@gmail.com
push dateMon, 02 Oct 2017 13:47:52 +0000
treeherdermozilla-beta@b7b894f5fad8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1403220
milestone57.0
Bug 1403220 - De-optimize the GetFontGroupForFrame function on Win32 to work around an MSVC PGO crash. r+a=RyanVM
layout/generic/nsTextFrame.cpp
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -2001,16 +2001,20 @@ 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();
 
@@ -2019,16 +2023,19 @@ 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->PresContext()->PresShell()->CreateReferenceRenderingContext();
   RefPtr<DrawTarget> dt = ctx->GetDrawTarget();
   return dt.forget();