mirror of
https://github.com/servo/servo.git
synced 2025-06-24 09:04:33 +01:00
Change time::profile's meta booleans to enums.
This makes these parameters self-documenting. This patch does not attempt to push those enums into the data structures that feed calls to this function. Fixes #4158.
This commit is contained in:
parent
b8444f96f8
commit
65575bf8a7
3 changed files with 41 additions and 23 deletions
|
@ -54,7 +54,7 @@ use servo_util::opts;
|
||||||
use servo_util::smallvec::{SmallVec, SmallVec1, VecLike};
|
use servo_util::smallvec::{SmallVec, SmallVec1, VecLike};
|
||||||
use servo_util::task::spawn_named_with_send_on_failure;
|
use servo_util::task::spawn_named_with_send_on_failure;
|
||||||
use servo_util::task_state;
|
use servo_util::task_state;
|
||||||
use servo_util::time::{TimeProfilerChan, profile};
|
use servo_util::time::{TimeProfilerChan, profile, TimeRootWindow, TimeIFrame, TimeIncremental, TimeFirstReflow};
|
||||||
use servo_util::time;
|
use servo_util::time;
|
||||||
use servo_util::workqueue::WorkQueue;
|
use servo_util::workqueue::WorkQueue;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
@ -396,7 +396,9 @@ impl LayoutTask {
|
||||||
},
|
},
|
||||||
ReflowMsg(data) => {
|
ReflowMsg(data) => {
|
||||||
profile(time::LayoutPerformCategory,
|
profile(time::LayoutPerformCategory,
|
||||||
Some((&data.url, data.iframe, self.first_reflow.get())),
|
Some((&data.url,
|
||||||
|
if data.iframe { TimeIFrame } else { TimeRootWindow },
|
||||||
|
if self.first_reflow.get() { TimeFirstReflow } else { TimeIncremental })),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| self.handle_reflow(&*data, possibly_locked_rw_data));
|
|| self.handle_reflow(&*data, possibly_locked_rw_data));
|
||||||
},
|
},
|
||||||
|
@ -562,8 +564,8 @@ impl LayoutTask {
|
||||||
// operation out.
|
// operation out.
|
||||||
parallel::traverse_flow_tree_preorder(layout_root,
|
parallel::traverse_flow_tree_preorder(layout_root,
|
||||||
&data.url,
|
&data.url,
|
||||||
data.iframe,
|
if data.iframe { TimeIFrame } else { TimeRootWindow },
|
||||||
self.first_reflow.get(),
|
if self.first_reflow.get() { TimeFirstReflow } else { TimeIncremental },
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
shared_layout_context,
|
shared_layout_context,
|
||||||
traversal);
|
traversal);
|
||||||
|
@ -612,7 +614,9 @@ impl LayoutTask {
|
||||||
rw_data: &mut RWGuard<'a>) {
|
rw_data: &mut RWGuard<'a>) {
|
||||||
let writing_mode = flow::base(layout_root.deref()).writing_mode;
|
let writing_mode = flow::base(layout_root.deref()).writing_mode;
|
||||||
profile(time::LayoutDispListBuildCategory,
|
profile(time::LayoutDispListBuildCategory,
|
||||||
Some((&data.url, data.iframe, self.first_reflow.get())),
|
Some((&data.url,
|
||||||
|
if data.iframe { TimeIFrame } else { TimeRootWindow },
|
||||||
|
if self.first_reflow.get() { TimeFirstReflow } else { TimeIncremental })),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
shared_layout_ctx.dirty =
|
shared_layout_ctx.dirty =
|
||||||
|
@ -632,8 +636,8 @@ impl LayoutTask {
|
||||||
Some(ref mut traversal) => {
|
Some(ref mut traversal) => {
|
||||||
parallel::build_display_list_for_subtree(layout_root,
|
parallel::build_display_list_for_subtree(layout_root,
|
||||||
&data.url,
|
&data.url,
|
||||||
data.iframe,
|
if data.iframe { TimeIFrame } else { TimeRootWindow },
|
||||||
self.first_reflow.get(),
|
if self.first_reflow.get() { TimeFirstReflow } else { TimeIncremental },
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
shared_layout_ctx,
|
shared_layout_ctx,
|
||||||
traversal);
|
traversal);
|
||||||
|
@ -758,8 +762,8 @@ impl LayoutTask {
|
||||||
|
|
||||||
let mut layout_root = profile(time::LayoutStyleRecalcCategory,
|
let mut layout_root = profile(time::LayoutStyleRecalcCategory,
|
||||||
Some((&data.url,
|
Some((&data.url,
|
||||||
data.iframe,
|
if data.iframe { TimeIFrame } else { TimeRootWindow },
|
||||||
self.first_reflow.get())),
|
if self.first_reflow.get() { TimeFirstReflow } else { TimeIncremental })),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
// Perform CSS selector matching and flow construction.
|
// Perform CSS selector matching and flow construction.
|
||||||
|
@ -777,7 +781,9 @@ impl LayoutTask {
|
||||||
});
|
});
|
||||||
|
|
||||||
profile(time::LayoutRestyleDamagePropagation,
|
profile(time::LayoutRestyleDamagePropagation,
|
||||||
Some((&data.url, data.iframe, self.first_reflow.get())),
|
Some((&data.url,
|
||||||
|
if data.iframe { TimeIFrame } else { TimeRootWindow },
|
||||||
|
if self.first_reflow.get() { TimeFirstReflow } else { TimeIncremental })),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
if opts::get().nonincremental_layout ||
|
if opts::get().nonincremental_layout ||
|
||||||
|
@ -798,7 +804,9 @@ impl LayoutTask {
|
||||||
// Perform the primary layout passes over the flow tree to compute the locations of all
|
// Perform the primary layout passes over the flow tree to compute the locations of all
|
||||||
// the boxes.
|
// the boxes.
|
||||||
profile(time::LayoutMainCategory,
|
profile(time::LayoutMainCategory,
|
||||||
Some((&data.url, data.iframe, self.first_reflow.get())),
|
Some((&data.url,
|
||||||
|
if data.iframe { TimeIFrame } else { TimeRootWindow },
|
||||||
|
if self.first_reflow.get() { TimeFirstReflow } else { TimeIncremental })),
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| {
|
|| {
|
||||||
let rw_data = rw_data.deref_mut();
|
let rw_data = rw_data.deref_mut();
|
||||||
|
|
|
@ -20,7 +20,7 @@ use wrapper::{PostorderNodeMutTraversal, UnsafeLayoutNode};
|
||||||
use wrapper::{PreorderDomTraversal, PostorderDomTraversal};
|
use wrapper::{PreorderDomTraversal, PostorderDomTraversal};
|
||||||
|
|
||||||
use servo_util::opts;
|
use servo_util::opts;
|
||||||
use servo_util::time::{TimeProfilerChan, profile};
|
use servo_util::time::{TimeProfilerChan, profile, TimerMetadataFrameType, TimerMetadataReflowType};
|
||||||
use servo_util::time;
|
use servo_util::time;
|
||||||
use servo_util::workqueue::{WorkQueue, WorkUnit, WorkerProxy};
|
use servo_util::workqueue::{WorkQueue, WorkUnit, WorkerProxy};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -423,8 +423,8 @@ pub fn traverse_dom_preorder(root: LayoutNode,
|
||||||
|
|
||||||
pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
||||||
url: &Url,
|
url: &Url,
|
||||||
iframe: bool,
|
iframe: TimerMetadataFrameType,
|
||||||
first_reflow: bool,
|
reflow_type: TimerMetadataReflowType,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
shared_layout_context: &SharedLayoutContext,
|
shared_layout_context: &SharedLayoutContext,
|
||||||
queue: &mut WorkQueue<*const SharedLayoutContext,UnsafeFlow>) {
|
queue: &mut WorkQueue<*const SharedLayoutContext,UnsafeFlow>) {
|
||||||
|
@ -436,7 +436,7 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
||||||
|
|
||||||
queue.data = shared_layout_context as *const _;
|
queue.data = shared_layout_context as *const _;
|
||||||
|
|
||||||
profile(time::LayoutParallelWarmupCategory, Some((url, iframe, first_reflow)), time_profiler_chan, || {
|
profile(time::LayoutParallelWarmupCategory, Some((url, iframe, reflow_type)), time_profiler_chan, || {
|
||||||
queue.push(WorkUnit {
|
queue.push(WorkUnit {
|
||||||
fun: assign_inline_sizes,
|
fun: assign_inline_sizes,
|
||||||
data: mut_owned_flow_to_unsafe_flow(root),
|
data: mut_owned_flow_to_unsafe_flow(root),
|
||||||
|
@ -450,14 +450,14 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
||||||
|
|
||||||
pub fn build_display_list_for_subtree(root: &mut FlowRef,
|
pub fn build_display_list_for_subtree(root: &mut FlowRef,
|
||||||
url: &Url,
|
url: &Url,
|
||||||
iframe: bool,
|
iframe: TimerMetadataFrameType,
|
||||||
first_reflow: bool,
|
reflow_type: TimerMetadataReflowType,
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
shared_layout_context: &SharedLayoutContext,
|
shared_layout_context: &SharedLayoutContext,
|
||||||
queue: &mut WorkQueue<*const SharedLayoutContext,UnsafeFlow>) {
|
queue: &mut WorkQueue<*const SharedLayoutContext,UnsafeFlow>) {
|
||||||
queue.data = shared_layout_context as *const _;
|
queue.data = shared_layout_context as *const _;
|
||||||
|
|
||||||
profile(time::LayoutParallelWarmupCategory, Some((url, iframe, first_reflow)), time_profiler_chan, || {
|
profile(time::LayoutParallelWarmupCategory, Some((url, iframe, reflow_type)), time_profiler_chan, || {
|
||||||
queue.push(WorkUnit {
|
queue.push(WorkUnit {
|
||||||
fun: compute_absolute_positions,
|
fun: compute_absolute_positions,
|
||||||
data: mut_owned_flow_to_unsafe_flow(root),
|
data: mut_owned_flow_to_unsafe_flow(root),
|
||||||
|
|
|
@ -246,10 +246,20 @@ impl TimeProfiler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deriving(Eq, PartialEq)]
|
||||||
|
pub enum TimerMetadataFrameType {
|
||||||
|
TimeRootWindow,
|
||||||
|
TimeIFrame,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[deriving(Eq, PartialEq)]
|
||||||
|
pub enum TimerMetadataReflowType {
|
||||||
|
TimeIncremental,
|
||||||
|
TimeFirstReflow,
|
||||||
|
}
|
||||||
|
|
||||||
pub fn profile<T>(category: TimeProfilerCategory,
|
pub fn profile<T>(category: TimeProfilerCategory,
|
||||||
// url, iframe?, first reflow?
|
meta: Option<(&Url, TimerMetadataFrameType, TimerMetadataReflowType)>,
|
||||||
meta: Option<(&Url, bool, bool)>,
|
|
||||||
time_profiler_chan: TimeProfilerChan,
|
time_profiler_chan: TimeProfilerChan,
|
||||||
callback: || -> T)
|
callback: || -> T)
|
||||||
-> T {
|
-> T {
|
||||||
|
@ -257,11 +267,11 @@ pub fn profile<T>(category: TimeProfilerCategory,
|
||||||
let val = callback();
|
let val = callback();
|
||||||
let end_time = precise_time_ns();
|
let end_time = precise_time_ns();
|
||||||
let ms = (end_time - start_time) as f64 / 1000000f64;
|
let ms = (end_time - start_time) as f64 / 1000000f64;
|
||||||
let meta = meta.map(|(url, iframe, first_reflow)|
|
let meta = meta.map(|(url, iframe, reflow_type)|
|
||||||
TimerMetadata {
|
TimerMetadata {
|
||||||
url: url.serialize(),
|
url: url.serialize(),
|
||||||
iframe: iframe,
|
iframe: iframe == TimeIFrame,
|
||||||
incremental: !first_reflow,
|
incremental: reflow_type == TimeIncremental,
|
||||||
});
|
});
|
||||||
time_profiler_chan.send(TimeMsg((category, meta), ms));
|
time_profiler_chan.send(TimeMsg((category, meta), ms));
|
||||||
return val;
|
return val;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue