mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Start reporting memory usage for Window and all nodes in all DOM trees for frame treese in script tasks.
This commit is contained in:
parent
c2497fcd49
commit
8620fe5995
33 changed files with 317 additions and 107 deletions
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::EventHandlerBinding::{OnErrorEventHandlerN
|
|||
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||
use dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::{self, WindowMethods, FrameRequestCallback};
|
||||
use dom::bindings::codegen::InheritTypes::{NodeCast, ElementCast, EventTargetCast};
|
||||
use dom::bindings::codegen::InheritTypes::{NodeCast, ElementCast, EventTargetCast, WindowDerived};
|
||||
use dom::bindings::global::global_object_for_js_object;
|
||||
use dom::bindings::error::{report_pending_exception, Fallible};
|
||||
use dom::bindings::error::Error::InvalidCharacter;
|
||||
|
@ -81,7 +81,7 @@ use std::sync::mpsc::{channel, Receiver};
|
|||
use time;
|
||||
|
||||
/// Current state of the window object
|
||||
#[derive(JSTraceable, Copy, Clone, Debug, PartialEq)]
|
||||
#[derive(JSTraceable, Copy, Clone, Debug, PartialEq, HeapSizeOf)]
|
||||
enum WindowState {
|
||||
Alive,
|
||||
Zombie, // Pipeline is closed, but the window hasn't been GCed yet.
|
||||
|
@ -106,15 +106,21 @@ pub enum ReflowReason {
|
|||
}
|
||||
|
||||
#[dom_struct]
|
||||
#[derive(HeapSizeOf)]
|
||||
pub struct Window {
|
||||
eventtarget: EventTarget,
|
||||
#[ignore_heap_size_of = "trait objects are hard"]
|
||||
script_chan: Box<ScriptChan+Send>,
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
control_chan: ScriptControlChan,
|
||||
console: MutNullableHeap<JS<Console>>,
|
||||
crypto: MutNullableHeap<JS<Crypto>>,
|
||||
navigator: MutNullableHeap<JS<Navigator>>,
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
image_cache_task: ImageCacheTask,
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
image_cache_chan: ImageCacheChan,
|
||||
#[ignore_heap_size_of = "TODO(#6911) newtypes containing unmeasurable types are hard"]
|
||||
compositor: DOMRefCell<ScriptListener>,
|
||||
browsing_context: DOMRefCell<Option<BrowsingContext>>,
|
||||
page: Rc<Page>,
|
||||
|
@ -129,13 +135,17 @@ pub struct Window {
|
|||
next_worker_id: Cell<WorkerId>,
|
||||
|
||||
/// For sending messages to the memory profiler.
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
mem_profiler_chan: mem::ProfilerChan,
|
||||
|
||||
/// For providing instructions to an optional devtools server.
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||
/// For sending timeline markers. Will be ignored if
|
||||
/// no devtools server
|
||||
#[ignore_heap_size_of = "TODO(#6909) need to measure HashSet"]
|
||||
devtools_markers: RefCell<HashSet<TimelineMarkerType>>,
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
devtools_marker_sender: RefCell<Option<IpcSender<TimelineMarker>>>,
|
||||
|
||||
/// A flag to indicate whether the developer tools have requested live updates of
|
||||
|
@ -160,27 +170,34 @@ pub struct Window {
|
|||
dom_static: GlobalStaticData,
|
||||
|
||||
/// The JavaScript runtime.
|
||||
#[ignore_heap_size_of = "Rc<T> is hard"]
|
||||
js_runtime: DOMRefCell<Option<Rc<Runtime>>>,
|
||||
|
||||
/// A handle for communicating messages to the layout task.
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
layout_chan: LayoutChan,
|
||||
|
||||
/// A handle to perform RPC calls into the layout, quickly.
|
||||
#[ignore_heap_size_of = "trait objects are hard"]
|
||||
layout_rpc: Box<LayoutRPC+'static>,
|
||||
|
||||
/// The port that we will use to join layout. If this is `None`, then layout is not running.
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
layout_join_port: DOMRefCell<Option<Receiver<()>>>,
|
||||
|
||||
/// The current size of the window, in pixels.
|
||||
window_size: Cell<Option<WindowSizeData>>,
|
||||
|
||||
/// Associated resource task for use by DOM objects like XMLHttpRequest
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
resource_task: Arc<ResourceTask>,
|
||||
|
||||
/// A handle for communicating messages to the storage task.
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
storage_task: StorageTask,
|
||||
|
||||
/// A handle for communicating messages to the constellation task.
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
constellation_chan: ConstellationChan,
|
||||
|
||||
/// Pending scroll to fragment event, if any
|
||||
|
@ -194,6 +211,7 @@ pub struct Window {
|
|||
pending_reflow_count: Cell<u32>,
|
||||
|
||||
/// A channel for communicating results of async scripts back to the webdriver server
|
||||
#[ignore_heap_size_of = "channels are hard"]
|
||||
webdriver_script_chan: RefCell<Option<IpcSender<WebDriverJSResult>>>,
|
||||
|
||||
/// The current state of the window object
|
||||
|
@ -1182,3 +1200,9 @@ fn debug_reflow_events(goal: &ReflowGoal, query_type: &ReflowQueryType, reason:
|
|||
|
||||
println!("{}", debug_msg);
|
||||
}
|
||||
|
||||
impl WindowDerived for EventTarget {
|
||||
fn is_window(&self) -> bool {
|
||||
self.type_id() == &EventTargetTypeId::Window
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue