Bug 1482782 - Part 6: Remove support for multiple static atom sources. r=njn,emilio
☠☠ backed out by f3f6f10edab2 ☠ ☠
authorCameron McCormack <cam@mcc.id.au>
Wed, 15 Aug 2018 15:46:42 +1000
changeset 486706 c834d4ca2eef0a7ace7aa7e480bba0ad76bbb8fb
parent 486705 887de0efbb67f436a241a60fea0fc4a001656cdd
child 486707 cb2dcb8590711584e1689583a75f66d7195bb550
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn, emilio
bugs1482782
milestone63.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 1482782 - Part 6: Remove support for multiple static atom sources. r=njn,emilio Summary: Depends On D3284 Reviewers: njn!, emilio! Tags: #secure-revision Bug #: 1482782 Differential Revision: https://phabricator.services.mozilla.com/D3285
layout/build/nsLayoutStatics.cpp
servo/components/style/gecko/regen_atoms.py
xpcom/ds/nsAtom.h
xpcom/ds/nsAtomTable.cpp
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -133,18 +133,16 @@ nsLayoutStatics::Initialize()
   nsresult rv;
 
   ContentParent::StartUp();
 
   nsCSSKeywords::AddRefTable();
   nsCSSProps::AddRefTable();
   nsColorNames::AddRefTable();
 
-  NS_SetStaticAtomsDone();
-
 #ifdef DEBUG
   nsCSSPseudoElements::AssertAtoms();
   nsCSSAnonBoxes::AssertAtoms();
 #endif
 
   StartupJSEnvironment();
   nsJSContext::EnsureStatics();
 
--- a/servo/components/style/gecko/regen_atoms.py
+++ b/servo/components/style/gecko/regen_atoms.py
@@ -15,80 +15,70 @@ sys.path.insert(0, os.path.join(os.path.
 
 import build
 
 PRELUDE = """
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-/* Autogenerated file created by components/style/gecko/binding_tools/regen_atoms.py, DO NOT EDIT DIRECTLY */
+/* Autogenerated file created by components/style/gecko/regen_atoms.py, DO NOT EDIT DIRECTLY */
 """[1:]   # NOQA: E501
 
 
-def gnu_symbolify(source, ident):
-    return "_ZN{}{}{}{}E".format(len(source.CLASS), source.CLASS, len(ident), ident)
+PATTERN = re.compile('^GK_ATOM\(([^,]*),[^"]*"([^"]*)",\s*([^,]*),\s*([^)]*)\)',
+                     re.MULTILINE)
+FILE = "include/nsGkAtomList.h"
+CLASS = "nsGkAtoms"
 
 
-def msvc64_symbolify(source, ident, ty):
-    return "?{}@{}@@2PEAV{}@@EA".format(ident, source.CLASS, ty)
+def gnu_symbolify(ident):
+    return "_ZN{}{}{}{}E".format(len(CLASS), CLASS, len(ident), ident)
 
 
-def msvc32_symbolify(source, ident, ty):
+def msvc64_symbolify(ident, ty):
+    return "?{}@{}@@2PEAV{}@@EA".format(ident, CLASS, ty)
+
+
+def msvc32_symbolify(ident, ty):
     # Prepend "\x01" to avoid LLVM prefixing the mangled name with "_".
     # See https://github.com/rust-lang/rust/issues/36097
-    return "\\x01?{}@{}@@2PAV{}@@A".format(ident, source.CLASS, ty)
-
-
-class GkAtomSource:
-    PATTERN = re.compile('^GK_ATOM\(([^,]*),[^"]*"([^"]*)",\s*([^,]*),\s*([^)]*)\)',
-                         re.MULTILINE)
-    FILE = "include/nsGkAtomList.h"
-    CLASS = "nsGkAtoms"
-
-
-SOURCES = [
-    GkAtomSource,
-]
+    return "\\x01?{}@{}@@2PAV{}@@A".format(ident, CLASS, ty)
 
 
 def map_atom(ident):
     if ident in {"box", "loop", "match", "mod", "ref",
                  "self", "type", "use", "where", "in"}:
         return ident + "_"
     return ident
 
 
 class Atom:
-    def __init__(self, source, ident, value, ty, atom_type):
-        self.ident = "{}_{}".format(source.CLASS, ident)
+    def __init__(self, ident, value, ty, atom_type):
+        self.ident = "{}_{}".format(CLASS, ident)
         self.original_ident = ident
         self.value = value
-        self.source = source
         # The Gecko type: "nsStaticAtom", "nsICSSPseudoElement", or "nsIAnonBoxPseudo"
         self.ty = ty
         # The type of atom: "Atom", "PseudoElement", "NonInheritingAnonBox",
         # or "InheritingAnonBox"
         self.atom_type = atom_type
         if self.is_pseudo() or self.is_anon_box():
             self.pseudo_ident = (ident.split("_", 1))[1]
         if self.is_anon_box():
             assert self.is_inheriting_anon_box() or self.is_non_inheriting_anon_box()
 
-    def cpp_class(self):
-        return self.source.CLASS
-
     def gnu_symbol(self):
-        return gnu_symbolify(self.source, self.original_ident)
+        return gnu_symbolify(self.original_ident)
 
     def msvc32_symbol(self):
-        return msvc32_symbolify(self.source, self.original_ident, self.ty)
+        return msvc32_symbolify(self.original_ident, self.ty)
 
     def msvc64_symbol(self):
-        return msvc64_symbolify(self.source, self.original_ident, self.ty)
+        return msvc64_symbolify(self.original_ident, self.ty)
 
     def type(self):
         return self.ty
 
     def capitalized_pseudo(self):
         return self.pseudo_ident[0].upper() + self.pseudo_ident[1:]
 
     def is_pseudo(self):
@@ -104,23 +94,22 @@ class Atom:
         return self.atom_type == "InheritingAnonBoxAtom"
 
     def is_tree_pseudo_element(self):
         return self.value.startswith(":-moz-tree-")
 
 
 def collect_atoms(objdir):
     atoms = []
-    for source in SOURCES:
-        path = os.path.abspath(os.path.join(objdir, source.FILE))
-        print("cargo:rerun-if-changed={}".format(path))
-        with open(path) as f:
-            content = f.read()
-            for result in source.PATTERN.finditer(content):
-                atoms.append(Atom(source, result.group(1), result.group(2), result.group(3), result.group(4)))
+    path = os.path.abspath(os.path.join(objdir, FILE))
+    print("cargo:rerun-if-changed={}".format(path))
+    with open(path) as f:
+        content = f.read()
+        for result in PATTERN.finditer(content):
+            atoms.append(Atom(result.group(1), result.group(2), result.group(3), result.group(4)))
     return atoms
 
 
 class FileAvoidWrite(BytesIO):
     """File-like object that buffers output and only writes if content changed."""
     def __init__(self, filename):
         BytesIO.__init__(self)
         self.name = filename
--- a/xpcom/ds/nsAtom.h
+++ b/xpcom/ds/nsAtom.h
@@ -230,19 +230,16 @@ already_AddRefed<nsAtom> NS_AtomizeMainT
 // Currently this function is only used in tests, which should probably remain
 // the case.
 nsrefcnt NS_GetNumberOfAtoms();
 
 // Return a pointer for a static atom for the string or null if there's no
 // static atom for this string.
 nsStaticAtom* NS_GetStaticAtom(const nsAString& aUTF16String);
 
-// Record that all static atoms have been inserted.
-void NS_SetStaticAtomsDone();
-
 class nsAtomString : public nsString
 {
 public:
   explicit nsAtomString(const nsAtom* aAtom) { aAtom->ToString(*this); }
 };
 
 class nsAtomCString : public nsCString
 {
--- a/xpcom/ds/nsAtomTable.cpp
+++ b/xpcom/ds/nsAtomTable.cpp
@@ -666,18 +666,20 @@ nsAtomTable::RegisterStaticAtoms(const n
     }
     he->mAtom = const_cast<nsStaticAtom*>(atom);
   }
 }
 
 void
 NS_RegisterStaticAtoms(const nsStaticAtom* aAtoms, size_t aAtomsLen)
 {
+  MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(gAtomTable);
   gAtomTable->RegisterStaticAtoms(aAtoms, aAtomsLen);
+  gStaticAtomsDone = true;
 }
 
 already_AddRefed<nsAtom>
 NS_Atomize(const char* aUTF8String)
 {
   MOZ_ASSERT(gAtomTable);
   return gAtomTable->Atomize(nsDependentCString(aUTF8String));
 }
@@ -829,23 +831,16 @@ nsAtomTable::GetStaticAtom(const nsAStri
   nsAtomSubTable& table = SelectSubTable(key);
   MutexAutoLock lock(table.mLock);
   AtomTableEntry* he = table.Search(key);
   return he && he->mAtom->IsStatic()
        ? static_cast<nsStaticAtom*>(he->mAtom)
        : nullptr;
 }
 
-void
-NS_SetStaticAtomsDone()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  gStaticAtomsDone = true;
-}
-
 void ToLowerCaseASCII(RefPtr<nsAtom>& aAtom)
 {
   // Assume the common case is that the atom is already ASCII lowercase.
   bool reAtomize = false;
   const nsDependentString existing(aAtom->GetUTF16String(), aAtom->GetLength());
   for (size_t i = 0; i < existing.Length(); ++i) {
     if (IS_ASCII_UPPER(existing[i])) {
       reAtomize = true;