mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #25918 - servo:vtable-pointers-are-not-comparable, r=jdm
Don't compare vtable pointers anymore
This commit is contained in:
commit
a0f14ceb7b
3 changed files with 32 additions and 15 deletions
|
@ -2728,7 +2728,7 @@ assert!(!obj.is_null());
|
|||
SetProxyReservedSlot(
|
||||
obj.get(),
|
||||
0,
|
||||
&PrivateValue(&*raw as *const %(concreteType)s as *const libc::c_void),
|
||||
&PrivateValue(raw.as_ptr() as *const %(concreteType)s as *const libc::c_void),
|
||||
);
|
||||
"""
|
||||
else:
|
||||
|
@ -2742,7 +2742,7 @@ assert!(!obj.is_null());
|
|||
JS_SetReservedSlot(
|
||||
obj.get(),
|
||||
DOM_OBJECT_SLOT,
|
||||
&PrivateValue(&*raw as *const %(concreteType)s as *const libc::c_void),
|
||||
&PrivateValue(raw.as_ptr() as *const %(concreteType)s as *const libc::c_void),
|
||||
);
|
||||
"""
|
||||
create = create % {"concreteType": self.descriptor.concreteType}
|
||||
|
@ -2765,11 +2765,11 @@ GetProtoObject(cx, scope, proto.handle_mut());
|
|||
assert!(!proto.is_null());
|
||||
|
||||
%(createObject)s
|
||||
raw.init_reflector(obj.get());
|
||||
let root = raw.reflect_with(obj.get());
|
||||
|
||||
%(copyUnforgeable)s
|
||||
|
||||
DomRoot::from_ref(&*raw)\
|
||||
DomRoot::from_ref(&*root)\
|
||||
""" % {'copyUnforgeable': unforgeable, 'createObject': create})
|
||||
|
||||
|
||||
|
@ -2809,12 +2809,12 @@ rooted!(in(*cx) let mut obj = ptr::null_mut::<JSObject>());
|
|||
create_global_object(
|
||||
cx,
|
||||
&Class.base,
|
||||
&*raw as *const %(concreteType)s as *const libc::c_void,
|
||||
raw.as_ptr() as *const %(concreteType)s as *const libc::c_void,
|
||||
_trace,
|
||||
obj.handle_mut());
|
||||
assert!(!obj.is_null());
|
||||
|
||||
raw.init_reflector(obj.get());
|
||||
let root = raw.reflect_with(obj.get());
|
||||
|
||||
let _ac = JSAutoRealm::new(*cx, obj.get());
|
||||
rooted!(in(*cx) let mut proto = ptr::null_mut::<JSObject>());
|
||||
|
@ -2828,7 +2828,7 @@ assert!(immutable);
|
|||
|
||||
%(unforgeable)s
|
||||
|
||||
DomRoot::from_ref(&*raw)\
|
||||
DomRoot::from_ref(&*root)\
|
||||
""" % values)
|
||||
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
use crate::dom::bindings::conversions::DerivedFrom;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::reflector::{DomObject, Reflector};
|
||||
use crate::dom::bindings::reflector::{DomObject, MutDomObject, Reflector};
|
||||
use crate::dom::bindings::trace::trace_reflector;
|
||||
use crate::dom::bindings::trace::JSTraceable;
|
||||
use crate::dom::node::Node;
|
||||
|
@ -262,7 +262,10 @@ impl RootCollection {
|
|||
unsafe fn unroot(&self, object: *const dyn JSTraceable) {
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
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) => {
|
||||
roots.remove(idx);
|
||||
},
|
||||
|
@ -385,15 +388,25 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Deref for MaybeUnreflectedDom<T>
|
||||
impl<T> Root<MaybeUnreflectedDom<T>>
|
||||
where
|
||||
T: DomObject,
|
||||
{
|
||||
type Target = T;
|
||||
pub fn as_ptr(&self) -> *const T {
|
||||
self.value.ptr.as_ptr()
|
||||
}
|
||||
}
|
||||
|
||||
fn deref(&self) -> &T {
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe { &*self.ptr.as_ptr() }
|
||||
impl<T> Root<MaybeUnreflectedDom<T>>
|
||||
where
|
||||
T: MutDomObject,
|
||||
{
|
||||
pub unsafe fn reflect_with(self, obj: *mut JSObject) -> DomRoot<T> {
|
||||
let ptr = self.as_ptr();
|
||||
drop(self);
|
||||
let root = DomRoot::from_ref(&*ptr);
|
||||
root.init_reflector(obj);
|
||||
root
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -891,7 +891,11 @@ impl RootedTraceableSet {
|
|||
unsafe fn remove(traceable: *const dyn JSTraceable) {
|
||||
ROOTED_TRACEABLES.with(|ref traceables| {
|
||||
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,
|
||||
None => unreachable!(),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue