Bug 1593642 - servo: Remove usage of opts::get() from style.
authorKitlith <kitlith@kitl.pw>
Mon, 04 Nov 2019 12:52:32 +0000
changeset 500344 b9f29a6dad9748917523f600d7da5e93f24d97be
parent 500343 62a3bc7b41375fb3ac4aae73bcf88abd0fb6c437
child 500345 c8685b4f6f0aff9100af233fd4177ed6bbb86334
push id114164
push useraiakab@mozilla.com
push dateTue, 05 Nov 2019 10:06:15 +0000
treeherdermozilla-inbound@4d585c7edc76 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1593642, 22854
milestone72.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 1593642 - servo: Remove usage of opts::get() from style. Part of #22854. Differential Revision: https://phabricator.services.mozilla.com/D51585
servo/components/style/context.rs
servo/components/style/traversal.rs
--- a/servo/components/style/context.rs
+++ b/servo/components/style/context.rs
@@ -98,24 +98,39 @@ const DEFAULT_STATISTICS_THRESHOLD: usiz
 fn get_env_usize(name: &str) -> Option<usize> {
     use std::env;
     env::var(name).ok().map(|s| {
         s.parse::<usize>()
             .expect("Couldn't parse environmental variable as usize")
     })
 }
 
+/// A global variable holding the state of
+/// `StyleSystemOptions::default().disable_style_sharing_cache`.
+/// See [#22854](https://github.com/servo/servo/issues/22854).
+#[cfg(feature = "servo")]
+pub static DEFAULT_DISABLE_STYLE_SHARING_CACHE: std::sync::atomic::AtomicBool =
+    std::sync::atomic::AtomicBool::new(false);
+
+/// A global variable holding the state of
+/// `StyleSystemOptions::default().dump_style_statistics`.
+/// See [#22854](https://github.com/servo/servo/issues/22854).
+#[cfg(feature = "servo")]
+pub static DEFAULT_DUMP_STYLE_STATISTICS: std::sync::atomic::AtomicBool =
+    std::sync::atomic::AtomicBool::new(false);
+
 impl Default for StyleSystemOptions {
     #[cfg(feature = "servo")]
     fn default() -> Self {
-        use servo_config::opts;
+        use std::sync::atomic::Ordering;
 
         StyleSystemOptions {
-            disable_style_sharing_cache: opts::get().disable_share_style_cache,
-            dump_style_statistics: opts::get().style_sharing_stats,
+            disable_style_sharing_cache: DEFAULT_DISABLE_STYLE_SHARING_CACHE
+                .load(Ordering::Relaxed),
+            dump_style_statistics: DEFAULT_DUMP_STYLE_STATISTICS.load(Ordering::Relaxed),
             style_statistics_threshold: DEFAULT_STATISTICS_THRESHOLD,
         }
     }
 
     #[cfg(feature = "gecko")]
     fn default() -> Self {
         StyleSystemOptions {
             disable_style_sharing_cache: get_env_bool("DISABLE_STYLE_SHARING_CACHE"),
--- a/servo/components/style/traversal.rs
+++ b/servo/components/style/traversal.rs
@@ -40,22 +40,29 @@ impl<E: TElement> PreTraverseToken<E> {
     }
 
     /// Returns the traversal root for the current traversal.
     pub(crate) fn traversal_root(self) -> Option<E> {
         self.0
     }
 }
 
+/// A global variable holding the state of
+/// `is_servo_nonincremental_layout()`.
+/// See [#22854](https://github.com/servo/servo/issues/22854).
+#[cfg(feature = "servo")]
+pub static IS_SERVO_NONINCREMENTAL_LAYOUT: std::sync::atomic::AtomicBool =
+    std::sync::atomic::AtomicBool::new(false);
+
 #[cfg(feature = "servo")]
 #[inline]
 fn is_servo_nonincremental_layout() -> bool {
-    use servo_config::opts;
+    use std::sync::atomic::Ordering;
 
-    opts::get().nonincremental_layout
+    IS_SERVO_NONINCREMENTAL_LAYOUT.load(Ordering::Relaxed)
 }
 
 #[cfg(not(feature = "servo"))]
 #[inline]
 fn is_servo_nonincremental_layout() -> bool {
     false
 }