mirror of
https://github.com/servo/servo.git
synced 2025-07-24 07:40:27 +01:00
Trace the prototype array on the global object.
This commit is contained in:
parent
c724444ccb
commit
453679fd1f
2 changed files with 18 additions and 3 deletions
|
@ -4166,9 +4166,13 @@ class CGClassTraceHook(CGAbstractClassHook):
|
||||||
args = [Argument('*mut JSTracer', 'trc'), Argument('*mut JSObject', 'obj')]
|
args = [Argument('*mut JSTracer', 'trc'), Argument('*mut JSObject', 'obj')]
|
||||||
CGAbstractClassHook.__init__(self, descriptor, TRACE_HOOK_NAME, 'void',
|
CGAbstractClassHook.__init__(self, descriptor, TRACE_HOOK_NAME, 'void',
|
||||||
args)
|
args)
|
||||||
|
self.traceGlobal = descriptor.isGlobal()
|
||||||
|
|
||||||
def generate_code(self):
|
def generate_code(self):
|
||||||
return CGGeneric("(*this).trace(%s);" % self.args[0].name)
|
body = [CGGeneric("(*this).trace(%s);" % self.args[0].name)]
|
||||||
|
if self.traceGlobal:
|
||||||
|
body += [CGGeneric("trace_global(trc, obj);")]
|
||||||
|
return CGList(body, "\n")
|
||||||
|
|
||||||
class CGClassConstructHook(CGAbstractExternMethod):
|
class CGClassConstructHook(CGAbstractExternMethod):
|
||||||
"""
|
"""
|
||||||
|
@ -4770,7 +4774,7 @@ class CGBindingRoot(CGThing):
|
||||||
'dom::bindings::utils::{DOMJSClass, JSCLASS_DOM_GLOBAL}',
|
'dom::bindings::utils::{DOMJSClass, JSCLASS_DOM_GLOBAL}',
|
||||||
'dom::bindings::utils::{find_enum_string_index, get_array_index_from_id}',
|
'dom::bindings::utils::{find_enum_string_index, get_array_index_from_id}',
|
||||||
'dom::bindings::utils::{get_property_on_prototype, get_proto_or_iface_array}',
|
'dom::bindings::utils::{get_property_on_prototype, get_proto_or_iface_array}',
|
||||||
'dom::bindings::utils::finalize_global',
|
'dom::bindings::utils::{finalize_global, trace_global}',
|
||||||
'dom::bindings::utils::has_property_on_prototype',
|
'dom::bindings::utils::has_property_on_prototype',
|
||||||
'dom::bindings::utils::is_platform_object',
|
'dom::bindings::utils::is_platform_object',
|
||||||
'dom::bindings::utils::{Reflectable}',
|
'dom::bindings::utils::{Reflectable}',
|
||||||
|
|
|
@ -10,6 +10,7 @@ use dom::bindings::conversions::{native_from_reflector_jsmanaged, is_dom_class};
|
||||||
use dom::bindings::error::{Error, ErrorResult, Fallible, throw_type_error};
|
use dom::bindings::error::{Error, ErrorResult, Fallible, throw_type_error};
|
||||||
use dom::bindings::global::GlobalRef;
|
use dom::bindings::global::GlobalRef;
|
||||||
use dom::bindings::js::{Temporary, Root, Rootable};
|
use dom::bindings::js::{Temporary, Root, Rootable};
|
||||||
|
use dom::bindings::trace::trace_object;
|
||||||
use dom::browsercontext;
|
use dom::browsercontext;
|
||||||
use dom::window;
|
use dom::window;
|
||||||
use util::namespace;
|
use util::namespace;
|
||||||
|
@ -26,7 +27,7 @@ use js::glue::{IsWrapper, RUST_JSID_IS_INT, RUST_JSID_TO_INT};
|
||||||
use js::jsapi::{JS_AlreadyHasOwnProperty, JS_NewFunction};
|
use js::jsapi::{JS_AlreadyHasOwnProperty, JS_NewFunction};
|
||||||
use js::jsapi::{JS_DefineProperties, JS_ForwardGetPropertyTo};
|
use js::jsapi::{JS_DefineProperties, JS_ForwardGetPropertyTo};
|
||||||
use js::jsapi::{JS_GetClass, JS_LinkConstructorAndPrototype, JS_GetStringCharsAndLength};
|
use js::jsapi::{JS_GetClass, JS_LinkConstructorAndPrototype, JS_GetStringCharsAndLength};
|
||||||
use js::jsapi::JSHandleObject;
|
use js::jsapi::{JSHandleObject, JSTracer};
|
||||||
use js::jsapi::JS_GetFunctionObject;
|
use js::jsapi::JS_GetFunctionObject;
|
||||||
use js::jsapi::{JS_HasPropertyById, JS_GetPrototype};
|
use js::jsapi::{JS_HasPropertyById, JS_GetPrototype};
|
||||||
use js::jsapi::{JS_GetProperty, JS_HasProperty, JS_SetProperty};
|
use js::jsapi::{JS_GetProperty, JS_HasProperty, JS_SetProperty};
|
||||||
|
@ -596,6 +597,16 @@ pub unsafe fn finalize_global(obj: *mut JSObject) {
|
||||||
Box::from_raw(get_proto_or_iface_array(obj) as *mut ProtoOrIfaceArray);
|
Box::from_raw(get_proto_or_iface_array(obj) as *mut ProtoOrIfaceArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Trace the resources held by reserved slots of a global object
|
||||||
|
pub unsafe fn trace_global(tracer: *mut JSTracer, obj: *mut JSObject) {
|
||||||
|
let array = get_proto_or_iface_array(obj) as *mut ProtoOrIfaceArray;
|
||||||
|
for &proto in (*array).iter() {
|
||||||
|
if !proto.is_null() {
|
||||||
|
trace_object(tracer, "prototype", proto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Callback to outerize windows when wrapping.
|
/// Callback to outerize windows when wrapping.
|
||||||
pub unsafe extern fn wrap_for_same_compartment(cx: *mut JSContext, obj: *mut JSObject) -> *mut JSObject {
|
pub unsafe extern fn wrap_for_same_compartment(cx: *mut JSContext, obj: *mut JSObject) -> *mut JSObject {
|
||||||
JS_ObjectToOuterObject(cx, obj)
|
JS_ObjectToOuterObject(cx, obj)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue