Don't compare the vtable pointers anymore when unrooting stuff

This commit is contained in:
Anthony Ramine 2020-03-06 18:55:35 +01:00
parent 05077d31c8
commit b5aa83f633
2 changed files with 9 additions and 2 deletions

View file

@ -262,7 +262,10 @@ impl RootCollection {
unsafe fn unroot(&self, object: *const dyn JSTraceable) { unsafe fn unroot(&self, object: *const dyn JSTraceable) {
debug_assert!(thread_state::get().is_script()); debug_assert!(thread_state::get().is_script());
let roots = &mut *self.roots.get(); let roots = &mut *self.roots.get();
match roots.iter().rposition(|r| *r == object) { match roots
.iter()
.rposition(|r| *r as *const () == object as *const ())
{
Some(idx) => { Some(idx) => {
roots.remove(idx); roots.remove(idx);
}, },

View file

@ -891,7 +891,11 @@ impl RootedTraceableSet {
unsafe fn remove(traceable: *const dyn JSTraceable) { unsafe fn remove(traceable: *const dyn JSTraceable) {
ROOTED_TRACEABLES.with(|ref traceables| { ROOTED_TRACEABLES.with(|ref traceables| {
let mut traceables = traceables.borrow_mut(); let mut traceables = traceables.borrow_mut();
let idx = match traceables.set.iter().rposition(|x| *x == traceable) { let idx = match traceables
.set
.iter()
.rposition(|x| *x as *const () == traceable as *const ())
{
Some(idx) => idx, Some(idx) => idx,
None => unreachable!(), None => unreachable!(),
}; };