aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/js.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-04-02 10:51:40 -0600
committerbors-servo <metajack+bors@gmail.com>2015-04-02 10:51:40 -0600
commit85808c1cdd39a3afdc9815247ceb6f0fb7e9a31b (patch)
tree6b47ab014bd87a2f1b172a7a5451d7fa9c9b2a26 /components/script/dom/bindings/js.rs
parent5457ec60983481fb436114d548f0872e274e420f (diff)
parentd1c13faf4be3307d7e2ba55f1b1046d230610c47 (diff)
downloadservo-85808c1cdd39a3afdc9815247ceb6f0fb7e9a31b.tar.gz
servo-85808c1cdd39a3afdc9815247ceb6f0fb7e9a31b.zip
auto merge of #5425 : pcwalton/servo/optimize-rooting, r=Ms2ger
This was showing up very high in instruction-level profiling. r? @jdm
Diffstat (limited to 'components/script/dom/bindings/js.rs')
-rw-r--r--components/script/dom/bindings/js.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs
index 687bd59e6b0..357a3282f9d 100644
--- a/components/script/dom/bindings/js.rs
+++ b/components/script/dom/bindings/js.rs
@@ -626,12 +626,12 @@ impl RootCollection {
}
}
- /// Track a stack-based root to ensure LIFO root ordering
- fn root<'b, T: Reflectable>(&self, untracked: &Root<T>) {
+ /// Track a stack-based root as a pointer to ensure LIFO root ordering.
+ fn root<'b>(&self, untracked_js_ptr: *mut JSObject) {
unsafe {
let roots = self.roots.get();
- (*roots).push(untracked.js_ptr);
- debug!(" rooting {:?}", untracked.js_ptr);
+ (*roots).push(untracked_js_ptr);
+ debug!(" rooting {:?}", untracked_js_ptr);
assert!(!(*roots).spilled());
}
}
@@ -668,15 +668,18 @@ impl<T: Reflectable> Root<T> {
/// Create a new stack-bounded root for the provided JS-owned value.
/// It cannot not outlive its associated `RootCollection`, and it contains
/// a `JSRef` which cannot outlive this new `Root`.
+ #[inline]
fn new(roots: &'static RootCollection, unrooted: NonZero<*const T>)
-> Root<T> {
- let root = Root {
+ let js_ptr = unsafe {
+ (**unrooted).reflector().get_jsobject()
+ };
+ roots.root(js_ptr);
+ Root {
root_list: roots,
ptr: unrooted,
- js_ptr: unsafe { (**unrooted).reflector().get_jsobject() },
- };
- roots.root(&root);
- root
+ js_ptr: js_ptr,
+ }
}
/// Obtain a safe reference to the wrapped JS owned-value that cannot