aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-03-27 21:21:56 -0400
committerGitHub <noreply@github.com>2018-03-27 21:21:56 -0400
commit339146ae1566fc35e47ccc4fba1471a9123d039d (patch)
treef0896fbfdf6d623e6ffc03c28716fef2491d6412 /components/script/script_thread.rs
parent97c12bd3927c057d5610b0295f0e8320b64af5e5 (diff)
parent7f7fc917586fa5ea9c0681f7a479c7ec8ad69019 (diff)
downloadservo-339146ae1566fc35e47ccc4fba1471a9123d039d.tar.gz
servo-339146ae1566fc35e47ccc4fba1471a9123d039d.zip
Auto merge of #20430 - aeweston98:aew-issue7084, r=jdm
Pass new method in CollectServoSizes to get size of ObjectPrivateVisitor <!-- Please describe your changes on the following line: --> These changes are the servo changes to allow the measurement of DOM objects with the ObjectPrivateVisitor API. Two new functions have been added MemoryReporter and get_size, which are passed as function pointers to two updated mozjs functions. Currently these changes rely on a branch version of mozjs, which has an [open pull request](https://github.com/servo/rust-mozjs/pull/409). --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #7084 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20430) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r--components/script/script_thread.rs37
1 files changed, 7 insertions, 30 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index d949e9d0b8c..6244228dc99 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -17,6 +17,8 @@
//! a page runs its course and the script thread returns to processing events in the main event
//! loop.
+extern crate itertools;
+
use bluetooth_traits::BluetoothRequest;
use canvas_traits::webgl::WebGLPipeline;
use devtools;
@@ -72,8 +74,6 @@ use js::glue::GetWindowProxyClass;
use js::jsapi::{JSAutoCompartment, JSContext, JS_SetWrapObjectCallbacks};
use js::jsapi::{JSTracer, SetWindowProxyClass};
use js::jsval::UndefinedValue;
-use malloc_size_of::MallocSizeOfOps;
-use mem::malloc_size_of_including_self;
use metrics::{MAX_TASK_NS, PaintTimeMetrics};
use microtask::{MicrotaskQueue, Microtask};
use msg::constellation_msg::{BrowsingContextId, PipelineId, PipelineNamespace, TopLevelBrowsingContextId};
@@ -82,7 +82,7 @@ use net_traits::{Metadata, NetworkError, ReferrerPolicy, ResourceThreads};
use net_traits::image_cache::{ImageCache, PendingImageResponse};
use net_traits::request::{CredentialsMode, Destination, RedirectMode, RequestInit};
use net_traits::storage_thread::StorageType;
-use profile_traits::mem::{self, OpaqueSender, Report, ReportKind, ReportsChan};
+use profile_traits::mem::{self, OpaqueSender, ReportsChan};
use profile_traits::time::{self, ProfilerCategory, profile};
use script_layout_interface::message::{self, Msg, NewLayoutThreadInfo, ReflowGoal};
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
@@ -1580,34 +1580,11 @@ impl ScriptThread {
}
fn collect_reports(&self, reports_chan: ReportsChan) {
- let mut path_seg = String::from("url(");
- let mut dom_tree_size = 0;
- let mut reports = vec![];
- // Servo uses vanilla jemalloc, which doesn't have a
- // malloc_enclosing_size_of function.
- let mut ops = MallocSizeOfOps::new(::servo_allocator::usable_size, None, None);
-
- for (_, document) in self.documents.borrow().iter() {
- let current_url = document.url();
-
- for child in document.upcast::<Node>().traverse_preorder() {
- dom_tree_size += malloc_size_of_including_self(&mut ops, &*child);
- }
- dom_tree_size += malloc_size_of_including_self(&mut ops, document.window());
-
- if reports.len() > 0 {
- path_seg.push_str(", ");
- }
- path_seg.push_str(current_url.as_str());
-
- reports.push(Report {
- path: path![format!("url({})", current_url.as_str()), "dom-tree"],
- kind: ReportKind::ExplicitJemallocHeapSize,
- size: dom_tree_size,
- });
- }
+ let documents = self.documents.borrow();
+ let urls = itertools::join(documents.iter().map(|(_, d)| d.url().to_string()), ", ");
+ let path_seg = format!("url({})", urls);
- path_seg.push_str(")");
+ let mut reports = vec![];
reports.extend(get_reports(self.get_cx(), path_seg));
reports_chan.send(reports);
}