Skip to content

Commit

Permalink
move reserved slot setting for DOM globals
Browse files Browse the repository at this point in the history
Moving this slot setting prior to initializing standard classes and
other initialization tasks means that we can effectively use JS_GC_ZEAL.

Fixes #6057.
  • Loading branch information
froydnj committed Oct 27, 2015
1 parent 3d39646 commit c82b6ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 2 additions & 4 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -2163,12 +2163,10 @@ def CreateBindingJSObject(descriptor, parent=None):
" create_dom_global(\n"
" cx,\n"
" &Class.base as *const js::jsapi::Class as *const JSClass,\n"
" raw as *const libc::c_void,\n"
" Some(%s))\n"
");\n"
"assert!(!obj.ptr.is_null());\n"
"\n"
"JS_SetReservedSlot(obj.ptr, DOM_OBJECT_SLOT,\n"
" PrivateValue(raw as *const libc::c_void));" % TRACE_HOOK_NAME)
"assert!(!obj.ptr.is_null());" % TRACE_HOOK_NAME)
else:
create += ("let obj = {\n"
" let _ac = JSAutoCompartment::new(cx, proto.ptr);\n"
Expand Down
4 changes: 3 additions & 1 deletion components/script/dom/bindings/utils.rs
Expand Up @@ -9,7 +9,7 @@ use dom::bindings::codegen::PrototypeList;
use dom::bindings::codegen::PrototypeList::MAX_PROTO_CHAIN_LENGTH;
use dom::bindings::conversions::native_from_handleobject;
use dom::bindings::conversions::private_from_proto_check;
use dom::bindings::conversions::{is_dom_class, jsstring_to_str};
use dom::bindings::conversions::{is_dom_class, jsstring_to_str, DOM_OBJECT_SLOT};
use dom::bindings::error::throw_type_error;
use dom::bindings::error::{Error, ErrorResult, Fallible, throw_invalid_this};
use dom::bindings::global::GlobalRef;
Expand Down Expand Up @@ -625,6 +625,7 @@ pub fn has_property_on_prototype(cx: *mut JSContext, proxy: HandleObject,

/// Create a DOM global object with the given class.
pub fn create_dom_global(cx: *mut JSContext, class: *const JSClass,
private: *const libc::c_void,
trace: JSTraceOp)
-> *mut JSObject {
unsafe {
Expand All @@ -640,6 +641,7 @@ pub fn create_dom_global(cx: *mut JSContext, class: *const JSClass,
return ptr::null_mut();
}
let _ac = JSAutoCompartment::new(cx, obj.ptr);
JS_SetReservedSlot(obj.ptr, DOM_OBJECT_SLOT, PrivateValue(private));
JS_InitStandardClasses(cx, obj.handle());
initialize_global(obj.ptr);
JS_FireOnNewGlobalObject(cx, obj.handle());
Expand Down

0 comments on commit c82b6ce

Please sign in to comment.