mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
#8539 Config preferences backend restructure
This commit is contained in:
parent
34fda66dfa
commit
8bfd4dc1e2
53 changed files with 1748 additions and 680 deletions
|
@ -2586,7 +2586,7 @@ class CGConstructorEnabled(CGAbstractMethod):
|
|||
pref = iface.getExtendedAttribute("Pref")
|
||||
if pref:
|
||||
assert isinstance(pref, list) and len(pref) == 1
|
||||
conditions.append('PREFS.get("%s").as_boolean().unwrap_or(false)' % pref[0])
|
||||
conditions.append('prefs::pref_map().get("%s").as_bool().unwrap_or(false)' % pref[0])
|
||||
|
||||
func = iface.getExtendedAttribute("Func")
|
||||
if func:
|
||||
|
@ -5977,7 +5977,8 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'crate::dom::globalscope::GlobalScope',
|
||||
'crate::mem::malloc_size_of_including_raw_self',
|
||||
'libc',
|
||||
'servo_config::prefs::PREFS',
|
||||
'servo_config::pref',
|
||||
'servo_config::prefs',
|
||||
'std::borrow::ToOwned',
|
||||
'std::cmp',
|
||||
'std::mem',
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use js::jsapi::JSContext;
|
||||
use js::rust::HandleObject;
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::prefs;
|
||||
|
||||
/// A container with a condition.
|
||||
pub struct Guard<T: Clone + Copy> {
|
||||
|
@ -48,7 +48,7 @@ pub enum Condition {
|
|||
impl Condition {
|
||||
unsafe fn is_satisfied(&self, cx: *mut JSContext, obj: HandleObject) -> bool {
|
||||
match *self {
|
||||
Condition::Pref(name) => PREFS.get(name).as_boolean().unwrap_or(false),
|
||||
Condition::Pref(name) => prefs::pref_map().get(name).as_bool().unwrap_or(false),
|
||||
Condition::Func(f) => f(cx, obj),
|
||||
Condition::Satisfied => true,
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ use crate::dom::svgsvgelement::SVGSVGElement;
|
|||
use crate::script_thread::ScriptThread;
|
||||
use html5ever::{LocalName, Prefix, QualName};
|
||||
use js::jsapi::JSAutoCompartment;
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::pref;
|
||||
|
||||
fn create_svg_element(
|
||||
name: QualName,
|
||||
|
@ -101,7 +101,7 @@ fn create_svg_element(
|
|||
})
|
||||
);
|
||||
|
||||
if !PREFS.get("dom.svg.enabled").as_boolean().unwrap_or(false) {
|
||||
if !pref!(dom.svg.enabled) {
|
||||
return Element::new(name.local, name.ns, prefix, document);
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ use script_traits::{AnimationState, DocumentActivity, MouseButton, MouseEventTyp
|
|||
use script_traits::{MsDuration, ScriptMsg, TouchEventType, TouchId, UntrustedNodeAddress};
|
||||
use servo_arc::Arc;
|
||||
use servo_atoms::Atom;
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::pref;
|
||||
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::{Cell, Ref, RefMut};
|
||||
|
@ -1090,16 +1090,9 @@ impl Document {
|
|||
let opt = self.last_click_info.borrow_mut().take();
|
||||
|
||||
if let Some((last_time, last_pos)) = opt {
|
||||
let DBL_CLICK_TIMEOUT = Duration::from_millis(
|
||||
PREFS
|
||||
.get("dom.document.dblclick_timeout")
|
||||
.as_u64()
|
||||
.unwrap_or(300),
|
||||
);
|
||||
let DBL_CLICK_DIST_THRESHOLD = PREFS
|
||||
.get("dom.document.dblclick_dist")
|
||||
.as_u64()
|
||||
.unwrap_or(1);
|
||||
let DBL_CLICK_TIMEOUT =
|
||||
Duration::from_millis(pref!(dom.document.dblclick_timeout) as u64);
|
||||
let DBL_CLICK_DIST_THRESHOLD = pref!(dom.document.dblclick_dist) as u64;
|
||||
|
||||
// Calculate distance between this click and the previous click.
|
||||
let line = click_pos - last_pos;
|
||||
|
@ -2423,11 +2416,7 @@ impl Document {
|
|||
local_name: &LocalName,
|
||||
is: Option<&LocalName>,
|
||||
) -> Option<Rc<CustomElementDefinition>> {
|
||||
if !PREFS
|
||||
.get("dom.customelements.enabled")
|
||||
.as_boolean()
|
||||
.unwrap_or(false)
|
||||
{
|
||||
if !pref!(dom.custom_elements.enabled) {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -3165,11 +3154,7 @@ impl Document {
|
|||
error = true;
|
||||
}
|
||||
|
||||
if PREFS
|
||||
.get("dom.fullscreen.test")
|
||||
.as_boolean()
|
||||
.unwrap_or(false)
|
||||
{
|
||||
if pref!(dom.fullscreen.test) {
|
||||
// For reftests we just take over the current window,
|
||||
// and don't try to really enter fullscreen.
|
||||
info!("Tests don't really enter fullscreen.");
|
||||
|
|
|
@ -42,7 +42,7 @@ use js::jsapi::JSContext;
|
|||
use js::rust::HandleValue;
|
||||
use profile_traits::ipc;
|
||||
use script_layout_interface::{HTMLCanvasData, HTMLCanvasDataSource};
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::pref;
|
||||
use std::cell::Ref;
|
||||
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
|
||||
|
||||
|
@ -232,7 +232,7 @@ impl HTMLCanvasElement {
|
|||
cx: *mut JSContext,
|
||||
options: HandleValue,
|
||||
) -> Option<DomRoot<WebGL2RenderingContext>> {
|
||||
if !PREFS.is_webgl2_enabled() {
|
||||
if !pref!(dom.webgl2.enabled) {
|
||||
return None;
|
||||
}
|
||||
if let Some(ctx) = self.context() {
|
||||
|
|
|
@ -64,7 +64,7 @@ use net_traits::request::{CredentialsMode, Destination, RequestInit};
|
|||
use net_traits::{CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseListener, Metadata};
|
||||
use net_traits::{NetworkError, ResourceFetchTiming, ResourceTimingType};
|
||||
use script_layout_interface::HTMLMediaData;
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::pref;
|
||||
use servo_media::player::frame::{Frame, FrameRenderer};
|
||||
use servo_media::player::{PlaybackState, Player, PlayerError, PlayerEvent, StreamType};
|
||||
use servo_media::ServoMedia;
|
||||
|
@ -1121,13 +1121,12 @@ impl HTMLMediaElement {
|
|||
.unwrap()
|
||||
.render_poster_frame(image);
|
||||
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
|
||||
if let Some(testing_on) = PREFS.get("media.testing.enabled").as_boolean() {
|
||||
if !testing_on {
|
||||
return;
|
||||
}
|
||||
if pref!(media.testing.enabled) {
|
||||
let window = window_from_node(self);
|
||||
let task_source = window.task_manager().media_element_task_source();
|
||||
task_source.queue_simple_event(self.upcast(), atom!("postershown"), &window);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ use dom_struct::dom_struct;
|
|||
use html5ever::{LocalName, Prefix};
|
||||
use parking_lot::RwLock;
|
||||
use servo_arc::Arc;
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::pref;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use style::attr::AttrValue;
|
||||
use style::media_queries::MediaList;
|
||||
|
@ -98,11 +98,7 @@ impl HTMLMetaElement {
|
|||
}
|
||||
|
||||
fn apply_viewport(&self) {
|
||||
if !PREFS
|
||||
.get("layout.viewport.enabled")
|
||||
.as_boolean()
|
||||
.unwrap_or(false)
|
||||
{
|
||||
if !pref!(layout.viewport.enabled) {
|
||||
return;
|
||||
}
|
||||
let element = self.upcast::<Element>();
|
||||
|
|
|
@ -16,7 +16,7 @@ use crate::dom::uievent::UIEvent;
|
|||
use crate::dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use euclid::Point2D;
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::pref;
|
||||
use std::cell::Cell;
|
||||
use std::default::Default;
|
||||
|
||||
|
@ -194,11 +194,7 @@ impl MouseEventMethods for MouseEvent {
|
|||
// This returns the same result as current gecko.
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which
|
||||
fn Which(&self) -> i32 {
|
||||
if PREFS
|
||||
.get("dom.mouseevent.which.enabled")
|
||||
.as_boolean()
|
||||
.unwrap_or(false)
|
||||
{
|
||||
if pref!(dom.mouse_event.which.enabled) {
|
||||
(self.button.get() + 1) as i32
|
||||
} else {
|
||||
0
|
||||
|
|
|
@ -50,7 +50,7 @@ use profile_traits::ipc;
|
|||
use script_traits::Painter;
|
||||
use script_traits::{DrawAPaintImageResult, PaintWorkletError};
|
||||
use servo_atoms::Atom;
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::pref;
|
||||
use servo_url::ServoUrl;
|
||||
use std::cell::Cell;
|
||||
use std::collections::hash_map::Entry;
|
||||
|
@ -439,10 +439,7 @@ impl PaintWorkletGlobalScope {
|
|||
.expect("Locking a painter.")
|
||||
.schedule_a_worklet_task(WorkletTask::Paint(task));
|
||||
|
||||
let timeout = PREFS
|
||||
.get("dom.worklet.timeout_ms")
|
||||
.as_u64()
|
||||
.unwrap_or(10u64);
|
||||
let timeout = pref!(dom.worklet.timeout_ms) as u64;
|
||||
|
||||
receiver
|
||||
.recv_timeout(Duration::from_millis(timeout))
|
||||
|
|
|
@ -22,7 +22,7 @@ use js::jsapi::{JSContext, JSObject};
|
|||
use js::jsval::{ObjectValue, UndefinedValue};
|
||||
#[cfg(target_os = "linux")]
|
||||
use servo_config::opts;
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::pref;
|
||||
use std::rc::Rc;
|
||||
#[cfg(target_os = "linux")]
|
||||
use tinyfiledialogs::{self, MessageBoxIcon, YesNo};
|
||||
|
@ -307,11 +307,7 @@ pub fn get_descriptor_permission_state(
|
|||
let state = if allowed_in_nonsecure_contexts(&permission_name) {
|
||||
PermissionState::Prompt
|
||||
} else {
|
||||
if PREFS
|
||||
.get("dom.permissions.testing.allowed_in_nonsecure_contexts")
|
||||
.as_boolean()
|
||||
.unwrap_or(false)
|
||||
{
|
||||
if pref!(dom.permissions.testing.allowed_in_nonsecure_contexts) {
|
||||
PermissionState::Granted
|
||||
} else {
|
||||
settings
|
||||
|
|
|
@ -35,7 +35,7 @@ use net_traits::{load_whole_resource, CustomResponseMediator, IpcSend};
|
|||
use script_traits::{
|
||||
ScopeThings, ServiceWorkerMsg, TimerEvent, WorkerGlobalScopeInit, WorkerScriptLoadOrigin,
|
||||
};
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::pref;
|
||||
use servo_rand::random;
|
||||
use servo_url::ServoUrl;
|
||||
use std::thread;
|
||||
|
@ -336,10 +336,7 @@ impl ServiceWorkerGlobalScope {
|
|||
thread::Builder::new()
|
||||
.name("SWTimeoutThread".to_owned())
|
||||
.spawn(move || {
|
||||
let sw_lifetime_timeout = PREFS
|
||||
.get("dom.serviceworker.timeout_seconds")
|
||||
.as_u64()
|
||||
.unwrap();
|
||||
let sw_lifetime_timeout = pref!(dom.serviceworker.timeout_seconds) as u64;
|
||||
thread::sleep(Duration::new(sw_lifetime_timeout, 0));
|
||||
let _ = timer_chan.send(());
|
||||
})
|
||||
|
|
|
@ -52,7 +52,7 @@ use profile_traits::time::{
|
|||
profile, ProfilerCategory, TimerMetadata, TimerMetadataFrameType, TimerMetadataReflowType,
|
||||
};
|
||||
use script_traits::DocumentActivity;
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::pref;
|
||||
use servo_url::ServoUrl;
|
||||
use std::borrow::Cow;
|
||||
use std::cell::Cell;
|
||||
|
@ -135,11 +135,7 @@ impl ServoParser {
|
|||
}
|
||||
|
||||
pub fn parse_html_document(document: &Document, input: DOMString, url: ServoUrl) {
|
||||
let parser = if PREFS
|
||||
.get("dom.servoparser.async_html_tokenizer.enabled")
|
||||
.as_boolean()
|
||||
.unwrap()
|
||||
{
|
||||
let parser = if pref!(dom.servoparser.async_html_tokenizer.enabled) {
|
||||
ServoParser::new(
|
||||
document,
|
||||
Tokenizer::AsyncHtml(self::async_html::Tokenizer::new(document, url, None)),
|
||||
|
|
|
@ -57,7 +57,7 @@ use js::rust::CustomAutoRooterGuard;
|
|||
use js::rust::{HandleObject, HandleValue};
|
||||
use js::typedarray;
|
||||
use script_traits::MsDuration;
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::prefs;
|
||||
use std::borrow::ToOwned;
|
||||
use std::ptr;
|
||||
use std::ptr::NonNull;
|
||||
|
@ -887,12 +887,15 @@ impl TestBindingMethods for TestBinding {
|
|||
#[allow(unsafe_code)]
|
||||
unsafe fn PassVariadicObject(&self, _: *mut JSContext, _: Vec<*mut JSObject>) {}
|
||||
fn BooleanMozPreference(&self, pref_name: DOMString) -> bool {
|
||||
PREFS.get(pref_name.as_ref()).as_boolean().unwrap_or(false)
|
||||
prefs::pref_map()
|
||||
.get(pref_name.as_ref())
|
||||
.as_bool()
|
||||
.unwrap_or(false)
|
||||
}
|
||||
fn StringMozPreference(&self, pref_name: DOMString) -> DOMString {
|
||||
PREFS
|
||||
prefs::pref_map()
|
||||
.get(pref_name.as_ref())
|
||||
.as_string()
|
||||
.as_str()
|
||||
.map(|s| DOMString::from(s))
|
||||
.unwrap_or_else(|| DOMString::new())
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ use net_traits::image_cache::ImageResponse;
|
|||
use pixels::{self, PixelFormat};
|
||||
use script_layout_interface::HTMLCanvasDataSource;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::pref;
|
||||
use std::cell::Cell;
|
||||
use std::cmp;
|
||||
use std::ptr::{self, NonNull};
|
||||
|
@ -173,10 +173,7 @@ impl WebGLRenderingContext {
|
|||
size: Size2D<u32>,
|
||||
attrs: GLContextAttributes,
|
||||
) -> Result<WebGLRenderingContext, String> {
|
||||
if let Some(true) = PREFS
|
||||
.get("webgl.testing.context_creation_error")
|
||||
.as_boolean()
|
||||
{
|
||||
if pref!(webgl.testing.context_creation_error) {
|
||||
return Err("WebGL context creation error forced by pref `webgl.testing.context_creation_error`".into());
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ use malloc_size_of::MallocSizeOfOps;
|
|||
use msg::constellation_msg::PipelineId;
|
||||
use profile_traits::mem::{Report, ReportKind, ReportsChan};
|
||||
use servo_config::opts;
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::pref;
|
||||
use std::cell::Cell;
|
||||
use std::fmt;
|
||||
use std::io::{stdout, Write};
|
||||
|
@ -375,204 +375,151 @@ unsafe fn new_rt_and_cx_with_parent(parent: Option<ParentRuntime>) -> Runtime {
|
|||
|
||||
// Enable or disable the JITs.
|
||||
let cx_opts = &mut *ContextOptionsRef(cx);
|
||||
if let Some(val) = PREFS.get("js.baseline.enabled").as_boolean() {
|
||||
cx_opts.set_baseline_(val);
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.ion.enabled").as_boolean() {
|
||||
cx_opts.set_ion_(val);
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.asmjs.enabled").as_boolean() {
|
||||
cx_opts.set_asmJS_(val);
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.wasm.enabled").as_boolean() {
|
||||
cx_opts.set_wasm_(val);
|
||||
if val {
|
||||
// If WASM is enabled without setting the buildIdOp,
|
||||
// initializing a module will report an out of memory error.
|
||||
// https://dxr.mozilla.org/mozilla-central/source/js/src/wasm/WasmTypes.cpp#458
|
||||
SetBuildIdOp(cx, Some(servo_build_id));
|
||||
}
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.wasm.baseline.enabled").as_boolean() {
|
||||
cx_opts.set_wasmBaseline_(val);
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.wasm.ion.enabled").as_boolean() {
|
||||
cx_opts.set_wasmIon_(val);
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.strict.enabled").as_boolean() {
|
||||
cx_opts.set_extraWarnings_(val);
|
||||
cx_opts.set_baseline_(pref!(js.baseline.enabled));
|
||||
cx_opts.set_ion_(pref!(js.ion.enabled));
|
||||
cx_opts.set_asmJS_(pref!(js.asmjs.enabled));
|
||||
let wasm_enabled = pref!(js.wasm.enabled);
|
||||
cx_opts.set_wasm_(wasm_enabled);
|
||||
if wasm_enabled {
|
||||
// If WASM is enabled without setting the buildIdOp,
|
||||
// initializing a module will report an out of memory error.
|
||||
// https://dxr.mozilla.org/mozilla-central/source/js/src/wasm/WasmTypes.cpp#458
|
||||
SetBuildIdOp(cx, Some(servo_build_id));
|
||||
}
|
||||
cx_opts.set_wasmBaseline_(pref!(js.wasm.baseline.enabled));
|
||||
cx_opts.set_wasmIon_(pref!(js.wasm.ion.enabled));
|
||||
cx_opts.set_extraWarnings_(pref!(js.strict.enabled));
|
||||
// TODO: handle js.strict.debug.enabled
|
||||
// TODO: handle js.throw_on_asmjs_validation_failure (needs new Spidermonkey)
|
||||
if let Some(val) = PREFS.get("js.native_regexp.enabled").as_boolean() {
|
||||
cx_opts.set_nativeRegExp_(val);
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.parallel_parsing.enabled").as_boolean() {
|
||||
JS_SetParallelParsingEnabled(cx, val);
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.offthread_compilation_enabled").as_boolean() {
|
||||
JS_SetOffthreadIonCompilationEnabled(cx, val);
|
||||
}
|
||||
if let Some(val) = PREFS
|
||||
.get("js.baseline.unsafe_eager_compilation.enabled")
|
||||
.as_boolean()
|
||||
{
|
||||
let trigger: i32 = if val { 0 } else { -1 };
|
||||
JS_SetGlobalJitCompilerOption(
|
||||
cx,
|
||||
JSJitCompilerOption::JSJITCOMPILER_BASELINE_WARMUP_TRIGGER,
|
||||
trigger as u32,
|
||||
);
|
||||
}
|
||||
if let Some(val) = PREFS
|
||||
.get("js.ion.unsafe_eager_compilation.enabled")
|
||||
.as_boolean()
|
||||
{
|
||||
let trigger: i64 = if val { 0 } else { -1 };
|
||||
JS_SetGlobalJitCompilerOption(
|
||||
cx,
|
||||
JSJitCompilerOption::JSJITCOMPILER_ION_WARMUP_TRIGGER,
|
||||
trigger as u32,
|
||||
);
|
||||
}
|
||||
cx_opts.set_nativeRegExp_(pref!(js.native_regex.enabled));
|
||||
JS_SetParallelParsingEnabled(cx, pref!(js.parallel_parsing.enabled));
|
||||
JS_SetOffthreadIonCompilationEnabled(cx, pref!(js.offthread_compilation.enabled));
|
||||
JS_SetGlobalJitCompilerOption(
|
||||
cx,
|
||||
JSJitCompilerOption::JSJITCOMPILER_BASELINE_WARMUP_TRIGGER,
|
||||
if pref!(js.baseline.unsafe_eager_compilation.enabled) {
|
||||
0
|
||||
} else {
|
||||
u32::max_value()
|
||||
},
|
||||
);
|
||||
JS_SetGlobalJitCompilerOption(
|
||||
cx,
|
||||
JSJitCompilerOption::JSJITCOMPILER_ION_WARMUP_TRIGGER,
|
||||
if pref!(js.ion.unsafe_eager_compilation.enabled) {
|
||||
0
|
||||
} else {
|
||||
u32::max_value()
|
||||
},
|
||||
);
|
||||
// TODO: handle js.discard_system_source.enabled
|
||||
// TODO: handle js.asyncstack.enabled (needs new Spidermonkey)
|
||||
// TODO: handle js.throw_on_debugee_would_run (needs new Spidermonkey)
|
||||
// TODO: handle js.dump_stack_on_debugee_would_run (needs new Spidermonkey)
|
||||
if let Some(val) = PREFS.get("js.werror.enabled").as_boolean() {
|
||||
cx_opts.set_werror_(val);
|
||||
}
|
||||
cx_opts.set_werror_(pref!(js.werror.enabled));
|
||||
// TODO: handle js.shared_memory.enabled
|
||||
if let Some(val) = PREFS.get("js.mem.high_water_mark").as_i64() {
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
JSGCParamKey::JSGC_MAX_MALLOC_BYTES,
|
||||
(pref!(js.mem.high_water_mark) * 1024 * 1024) as u32,
|
||||
);
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
JSGCParamKey::JSGC_MAX_BYTES,
|
||||
in_range(pref!(js.mem.max), 1, 0x100)
|
||||
.map(|val| (val * 1024 * 1024) as u32)
|
||||
.unwrap_or(u32::max_value()),
|
||||
);
|
||||
// NOTE: This is disabled above, so enabling it here will do nothing for now.
|
||||
let js_gc_mode = if pref!(js.mem.gc.incremental.enabled) {
|
||||
JSGCMode::JSGC_MODE_INCREMENTAL
|
||||
} else if pref!(js.mem.gc.per_zone.enabled) {
|
||||
JSGCMode::JSGC_MODE_ZONE
|
||||
} else {
|
||||
JSGCMode::JSGC_MODE_GLOBAL
|
||||
};
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_MODE, js_gc_mode as u32);
|
||||
if let Some(val) = in_range(pref!(js.mem.gc.incremental.slice_ms), 0, 100_000) {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_SLICE_TIME_BUDGET, val as u32);
|
||||
}
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
JSGCParamKey::JSGC_COMPACTING_ENABLED,
|
||||
pref!(js.mem.gc.compacting.enabled) as u32,
|
||||
);
|
||||
|
||||
if let Some(val) = in_range(pref!(js.mem.gc.high_frequency_time_limit_ms), 0, 10_000) {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_HIGH_FREQUENCY_TIME_LIMIT, val as u32);
|
||||
}
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
JSGCParamKey::JSGC_DYNAMIC_MARK_SLICE,
|
||||
pref!(js.mem.gc.dynamic_mark_slice.enabled) as u32,
|
||||
);
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
JSGCParamKey::JSGC_DYNAMIC_HEAP_GROWTH,
|
||||
pref!(js.mem.gc.dynamic_heap_growth.enabled) as u32,
|
||||
);
|
||||
if let Some(val) = in_range(pref!(js.mem.gc.low_frequency_heap_growth), 0, 10_000) {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_LOW_FREQUENCY_HEAP_GROWTH, val as u32);
|
||||
}
|
||||
if let Some(val) = in_range(pref!(js.mem.gc.high_frequency_heap_growth_min), 0, 10_000) {
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
JSGCParamKey::JSGC_MAX_MALLOC_BYTES,
|
||||
val as u32 * 1024 * 1024,
|
||||
JSGCParamKey::JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN,
|
||||
val as u32,
|
||||
);
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.mem.max").as_i64() {
|
||||
let max = if val <= 0 || val >= 0x1000 {
|
||||
-1
|
||||
} else {
|
||||
val * 1024 * 1024
|
||||
};
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_MAX_BYTES, max as u32);
|
||||
if let Some(val) = in_range(pref!(js.mem.gc.high_frequency_heap_growth_max), 0, 10_000) {
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
JSGCParamKey::JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX,
|
||||
val as u32,
|
||||
);
|
||||
}
|
||||
// NOTE: This is disabled above, so enabling it here will do nothing for now.
|
||||
if let Some(val) = PREFS.get("js.mem.gc.incremental.enabled").as_boolean() {
|
||||
let compartment = if let Some(val) = PREFS.get("js.mem.gc.per_zone.enabled").as_boolean() {
|
||||
val
|
||||
} else {
|
||||
false
|
||||
};
|
||||
let mode = if val {
|
||||
JSGCMode::JSGC_MODE_INCREMENTAL
|
||||
} else if compartment {
|
||||
JSGCMode::JSGC_MODE_ZONE
|
||||
} else {
|
||||
JSGCMode::JSGC_MODE_GLOBAL
|
||||
};
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_MODE, mode as u32);
|
||||
if let Some(val) = in_range(pref!(js.mem.gc.high_frequency_low_limit_mb), 0, 10_000) {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_HIGH_FREQUENCY_LOW_LIMIT, val as u32);
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.mem.gc.incremental.slice_ms").as_i64() {
|
||||
if val >= 0 && val < 100000 {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_SLICE_TIME_BUDGET, val as u32);
|
||||
}
|
||||
if let Some(val) = in_range(pref!(js.mem.gc.high_frequency_high_limit_mb), 0, 10_000) {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_HIGH_FREQUENCY_HIGH_LIMIT, val as u32);
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.mem.gc.compacting.enabled").as_boolean() {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_COMPACTING_ENABLED, val as u32);
|
||||
if let Some(val) = in_range(pref!(js.mem.gc.allocation_threshold_factor), 0, 10_000) {
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
JSGCParamKey::JSGC_ALLOCATION_THRESHOLD_FACTOR,
|
||||
val as u32,
|
||||
);
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.mem.gc.high_frequency_time_limit_ms").as_i64() {
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_HIGH_FREQUENCY_TIME_LIMIT, val as u32);
|
||||
}
|
||||
if let Some(val) = in_range(
|
||||
pref!(js.mem.gc.allocation_threshold_avoid_interrupt_factor),
|
||||
0,
|
||||
10_000,
|
||||
) {
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
JSGCParamKey::JSGC_ALLOCATION_THRESHOLD_FACTOR_AVOID_INTERRUPT,
|
||||
val as u32,
|
||||
);
|
||||
}
|
||||
if let Some(val) = PREFS
|
||||
.get("js.mem.gc.dynamic_mark_slice.enabled")
|
||||
.as_boolean()
|
||||
{
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_DYNAMIC_MARK_SLICE, val as u32);
|
||||
if let Some(val) = in_range(pref!(js.mem.gc.empty_chunk_count_min), 0, 10_000) {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_MIN_EMPTY_CHUNK_COUNT, val as u32);
|
||||
}
|
||||
if let Some(val) = PREFS
|
||||
.get("js.mem.gc.dynamic_heap_growth.enabled")
|
||||
.as_boolean()
|
||||
{
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_DYNAMIC_HEAP_GROWTH, val as u32);
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.mem.gc.low_frequency_heap_growth").as_i64() {
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_LOW_FREQUENCY_HEAP_GROWTH, val as u32);
|
||||
}
|
||||
}
|
||||
if let Some(val) = PREFS
|
||||
.get("js.mem.gc.high_frequency_heap_growth_min")
|
||||
.as_i64()
|
||||
{
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
JSGCParamKey::JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN,
|
||||
val as u32,
|
||||
);
|
||||
}
|
||||
}
|
||||
if let Some(val) = PREFS
|
||||
.get("js.mem.gc.high_frequency_heap_growth_max")
|
||||
.as_i64()
|
||||
{
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
JSGCParamKey::JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX,
|
||||
val as u32,
|
||||
);
|
||||
}
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.mem.gc.high_frequency_low_limit_mb").as_i64() {
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_HIGH_FREQUENCY_LOW_LIMIT, val as u32);
|
||||
}
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.mem.gc.high_frequency_high_limit_mb").as_i64() {
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_HIGH_FREQUENCY_HIGH_LIMIT, val as u32);
|
||||
}
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.mem.gc.allocation_threshold_factor").as_i64() {
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
JSGCParamKey::JSGC_ALLOCATION_THRESHOLD_FACTOR,
|
||||
val as u32,
|
||||
);
|
||||
}
|
||||
}
|
||||
if let Some(val) = PREFS
|
||||
.get("js.mem.gc.allocation_threshold_avoid_interrupt_factor")
|
||||
.as_i64()
|
||||
{
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
JSGCParamKey::JSGC_ALLOCATION_THRESHOLD_FACTOR_AVOID_INTERRUPT,
|
||||
val as u32,
|
||||
);
|
||||
}
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.mem.gc.empty_chunk_count_min").as_i64() {
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_MIN_EMPTY_CHUNK_COUNT, val as u32);
|
||||
}
|
||||
}
|
||||
if let Some(val) = PREFS.get("js.mem.gc.empty_chunk_count_max").as_i64() {
|
||||
if val >= 0 && val < 10000 {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_MAX_EMPTY_CHUNK_COUNT, val as u32);
|
||||
}
|
||||
if let Some(val) = in_range(pref!(js.mem.gc.empty_chunk_count_max), 0, 10_000) {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_MAX_EMPTY_CHUNK_COUNT, val as u32);
|
||||
}
|
||||
|
||||
Runtime(runtime)
|
||||
}
|
||||
|
||||
fn in_range<T: PartialOrd + Copy>(val: T, min: T, max: T) -> Option<T> {
|
||||
if val < min || val >= max {
|
||||
None
|
||||
} else {
|
||||
Some(val)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn get_size(obj: *mut JSObject) -> usize {
|
||||
match get_dom_class(obj) {
|
||||
|
@ -737,11 +684,11 @@ unsafe extern "C" fn servo_build_id(build_id: *mut BuildIdCharVector) -> bool {
|
|||
unsafe fn set_gc_zeal_options(cx: *mut JSContext) {
|
||||
use js::jsapi::{JS_SetGCZeal, JS_DEFAULT_ZEAL_FREQ};
|
||||
|
||||
let level = match PREFS.get("js.mem.gc.zeal.level").as_i64() {
|
||||
let level = match pref!(js.mem.gc.zeal.level) {
|
||||
Some(level @ 0...14) => level as u8,
|
||||
_ => return,
|
||||
};
|
||||
let frequency = match PREFS.get("js.mem.gc.zeal.frequency").as_i64() {
|
||||
let frequency = match pref!(js.mem.gc.zeal.frequency) {
|
||||
Some(frequency) if frequency >= 0 => frequency as u32,
|
||||
_ => JS_DEFAULT_ZEAL_FREQ,
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@ use ipc_channel::ipc::{self, IpcSender};
|
|||
use ipc_channel::router::ROUTER;
|
||||
use net_traits::{CoreResourceMsg, CustomResponseMediator};
|
||||
use script_traits::{DOMMessage, SWManagerMsg, SWManagerSenders, ScopeThings, ServiceWorkerMsg};
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::pref;
|
||||
use servo_url::ServoUrl;
|
||||
use std::collections::HashMap;
|
||||
use std::thread;
|
||||
|
@ -206,8 +206,5 @@ impl ServiceWorkerManager {
|
|||
}
|
||||
|
||||
pub fn serviceworker_enabled() -> bool {
|
||||
PREFS
|
||||
.get("dom.serviceworker.enabled")
|
||||
.as_boolean()
|
||||
.unwrap_or(false)
|
||||
pref!(dom.serviceworker.enabled)
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ use js::rust::HandleValue;
|
|||
use script_traits::{precise_time_ms, MsDuration};
|
||||
use script_traits::{TimerEvent, TimerEventId, TimerEventRequest};
|
||||
use script_traits::{TimerSchedulerMsg, TimerSource};
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_config::pref;
|
||||
use std::cell::Cell;
|
||||
use std::cmp::{self, Ord, Ordering};
|
||||
use std::collections::HashMap;
|
||||
|
@ -227,10 +227,7 @@ impl OneshotTimers {
|
|||
}
|
||||
|
||||
pub fn slow_down(&self) {
|
||||
let duration = PREFS
|
||||
.get("js.timers.minimum_duration")
|
||||
.as_u64()
|
||||
.unwrap_or(1000);
|
||||
let duration = pref!(js.timers.minimum_duration) as u64;
|
||||
self.js_timers.set_min_duration(MsDuration::new(duration));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue