Bug 1362599 - Guard against threadsafety issues in lang group stuff. r=heycam
authorManish Goregaokar <manishearth@gmail.com>
Sat, 20 May 2017 21:44:37 +0200
changeset 359776 57944331d42935841ae4455a50efa5d93e076b03
parent 359775 ed2b154ae61ff25f42e6b94bb435f9d20ea20a4c
child 359777 551b26ca92b3172a292454829184637539151580
push id31857
push userphilringnalda@gmail.com
push dateSun, 21 May 2017 20:00:29 +0000
treeherdermozilla-central@cf9f9525e4d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1362599
milestone55.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 1362599 - Guard against threadsafety issues in lang group stuff. r=heycam
intl/locale/nsLanguageAtomService.cpp
js/src/devtools/rootAnalysis/analyzeHeapWrites.js
layout/base/StaticPresData.cpp
layout/style/ServoSpecifiedValues.cpp
--- a/intl/locale/nsLanguageAtomService.cpp
+++ b/intl/locale/nsLanguageAtomService.cpp
@@ -65,16 +65,17 @@ nsIAtom*
 nsLanguageAtomService::GetLanguageGroup(nsIAtom* aLanguage,
                                         nsresult* aError)
 {
   nsIAtom* retVal;
 
   retVal = mLangToGroup.GetWeak(aLanguage);
 
   if (!retVal) {
+    MOZ_ASSERT(NS_IsMainThread(), "Should not append to cache off main thread");
     nsCOMPtr<nsIAtom> uncached = GetUncachedLanguageGroup(aLanguage, aError);
     retVal = uncached.get();
 
     // The hashtable will keep an owning reference to the atom
     mLangToGroup.Put(aLanguage, uncached);
   }
 
   return retVal;
--- a/js/src/devtools/rootAnalysis/analyzeHeapWrites.js
+++ b/js/src/devtools/rootAnalysis/analyzeHeapWrites.js
@@ -202,16 +202,17 @@ function treatAsSafeArgument(entry, varN
         ["Gecko_ClearWillChange", "aDisplay", null],
         ["Gecko_AppendWillChange", "aDisplay", null],
         ["Gecko_CopyWillChangeFrom", "aDest", null],
         ["Gecko_InitializeImageCropRect", "aImage", null],
         ["Gecko_CopyShapeSourceFrom", "aDst", null],
         ["Gecko_DestroyShapeSource", "aShape", null],
         ["Gecko_StyleShapeSource_SetURLValue", "aShape", null],
         ["Gecko_nsFont_InitSystem", "aDest", null],
+        ["Gecko_nsStyleFont_FixupNoneGeneric", "aFont", null],
         ["Gecko_StyleTransition_SetUnsupportedProperty", "aTransition", null],
         ["Gecko_AddPropertyToSet", "aPropertySet", "null"],
     ];
     for (var [entryMatch, varMatch, csuMatch] of whitelist) {
         assert(entryMatch || varMatch || csuMatch);
         if (entryMatch && !nameMatches(entry.name, entryMatch))
             continue;
         if (varMatch && !nameMatches(varName, varMatch))
--- a/layout/base/StaticPresData.cpp
+++ b/layout/base/StaticPresData.cpp
@@ -277,21 +277,23 @@ StaticPresData::GetFontPrefsForLangHelpe
       if (prefs->mLangGroup == langGroupAtom) {
         return prefs;
       }
       if (!prefs->mNext) {
         break;
       }
       prefs = prefs->mNext;
     }
-
+    MOZ_ASSERT(NS_IsMainThread(), "Should not append to cache off main thread");
     // nothing cached, so go on and fetch the prefs for this lang group:
     prefs = prefs->mNext = new LangGroupFontPrefs;
   }
 
+  MOZ_ASSERT(NS_IsMainThread(), "Should not append to cache off main thread");
+
   prefs->Initialize(langGroupAtom);
 
   return prefs;
 }
 
 const nsFont*
 StaticPresData::GetDefaultFontHelper(uint8_t aFontID, nsIAtom *aLanguage,
                                      const LangGroupFontPrefs* aPrefs) const
--- a/layout/style/ServoSpecifiedValues.cpp
+++ b/layout/style/ServoSpecifiedValues.cpp
@@ -43,16 +43,22 @@ ServoSpecifiedValues::PropertyIsSet(nsCS
 }
 
 void
 ServoSpecifiedValues::SetIdentStringValue(nsCSSPropertyID aId,
                                           const nsString& aValue)
 {
   nsCOMPtr<nsIAtom> atom = NS_Atomize(aValue);
   Servo_DeclarationBlock_SetIdentStringValue(mDecl, aId, atom);
+  if (aId == eCSSProperty__x_lang) {
+    // This forces the lang prefs result to be cached
+    // so that we can access them off main thread during traversal
+    mPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID,
+                                 atom);
+  }
 }
 
 void
 ServoSpecifiedValues::SetKeywordValue(nsCSSPropertyID aId, int32_t aValue)
 {
   Servo_DeclarationBlock_SetKeywordValue(mDecl, aId, aValue);
 }