servo: Merge #17672 - Use boxed slice instead of vec for FuntionTimerCallback (from sadmansk:heap_in_box); r=jdm

<!-- Please describe your changes on the following line: -->
Added `fn trace()` implementation for `Box<[T]>` type, and change FunctionTimerCallback to store boxed slices for heap values instead of Vector.

---
<!-- 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 #17611

<!-- Either: -->
- [x] These changes do not require tests

<!-- 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. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 749891e48ec6faa14447b299c48887754872e497

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : c2b1dee39ef62fd78b951b6c02eb0e1df9ede355
This commit is contained in:
Sadman Kazi 2017-07-11 18:55:18 -07:00
Родитель 314ef330a0
Коммит abc2faf829
2 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -177,6 +177,14 @@ unsafe impl<T: JSTraceable + ?Sized> JSTraceable for Box<T> {
}
}
unsafe impl<T: JSTraceable> JSTraceable for [T] {
unsafe fn trace(&self, trc: *mut JSTracer) {
for e in self.iter() {
e.trace(trc);
}
}
}
unsafe impl<T: JSTraceable + Copy> JSTraceable for Cell<T> {
unsafe fn trace(&self, trc: *mut JSTracer) {
self.get().trace(trc)

Просмотреть файл

@ -350,7 +350,7 @@ pub enum TimerCallback {
#[derive(JSTraceable, Clone)]
enum InternalTimerCallback {
StringTimerCallback(DOMString),
FunctionTimerCallback(Rc<Function>, Rc<Vec<Heap<JSVal>>>),
FunctionTimerCallback(Rc<Function>, Rc<Box<[Heap<JSVal>]>>),
}
impl HeapSizeOf for InternalTimerCallback {
@ -392,7 +392,7 @@ impl JsTimers {
for (i, item) in arguments.iter().enumerate() {
args.get_mut(i).unwrap().set(item.get());
}
InternalTimerCallback::FunctionTimerCallback(function, Rc::new(args))
InternalTimerCallback::FunctionTimerCallback(function, Rc::new(args.into_boxed_slice()))
}
};