mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
removing mutHeapJs references
changes as per comments
This commit is contained in:
parent
c62973b77b
commit
2996d3a413
7 changed files with 23 additions and 67 deletions
|
@ -5,7 +5,7 @@
|
|||
//! Base classes to work with IDL callbacks.
|
||||
|
||||
use dom::bindings::error::{Error, Fallible, report_pending_exception};
|
||||
use dom::bindings::js::{JS, Root, MutHeapJSVal};
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::reflector::DomObject;
|
||||
use dom::bindings::settings_stack::{AutoEntryScript, AutoIncumbentScript};
|
||||
use dom::globalscope::GlobalScope;
|
||||
|
@ -39,7 +39,7 @@ pub enum ExceptionHandling {
|
|||
pub struct CallbackObject {
|
||||
/// The underlying `JSObject`.
|
||||
callback: Heap<*mut JSObject>,
|
||||
permanent_js_root: MutHeapJSVal,
|
||||
permanent_js_root: Heap<JSVal>,
|
||||
|
||||
/// The ["callback context"], that is, the global to use as incumbent
|
||||
/// global when calling the callback.
|
||||
|
@ -67,7 +67,7 @@ impl CallbackObject {
|
|||
fn new() -> CallbackObject {
|
||||
CallbackObject {
|
||||
callback: Heap::default(),
|
||||
permanent_js_root: MutHeapJSVal::new(),
|
||||
permanent_js_root: Heap::default(),
|
||||
incumbent: GlobalScope::incumbent().map(|i| JS::from_ref(&*i)),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,8 +31,7 @@ use dom::bindings::trace::JSTraceable;
|
|||
use dom::bindings::trace::trace_reflector;
|
||||
use dom::node::Node;
|
||||
use heapsize::HeapSizeOf;
|
||||
use js::jsapi::{Heap, JSObject, JSTracer};
|
||||
use js::jsval::JSVal;
|
||||
use js::jsapi::{JSObject, JSTracer};
|
||||
use script_layout_interface::TrustedNodeAddress;
|
||||
use script_thread::STACK_ROOTS;
|
||||
use std::cell::UnsafeCell;
|
||||
|
@ -229,49 +228,6 @@ impl LayoutJS<Node> {
|
|||
}
|
||||
}
|
||||
|
||||
/// A holder that provides interior mutability for GC-managed JSVals.
|
||||
///
|
||||
/// Must be used in place of traditional interior mutability to ensure proper
|
||||
/// GC barriers are enforced.
|
||||
#[must_root]
|
||||
#[derive(JSTraceable)]
|
||||
pub struct MutHeapJSVal {
|
||||
val: UnsafeCell<Heap<JSVal>>,
|
||||
}
|
||||
|
||||
impl MutHeapJSVal {
|
||||
/// Create a new `MutHeapJSVal`.
|
||||
pub fn new() -> MutHeapJSVal {
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
MutHeapJSVal {
|
||||
val: UnsafeCell::new(Heap::default()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Set this `MutHeapJSVal` to the given value, calling write barriers as
|
||||
/// appropriate.
|
||||
pub fn set(&self, val: JSVal) {
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe {
|
||||
let cell = self.val.get();
|
||||
(*cell).set(val);
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the value in this `MutHeapJSVal`, calling read barriers as appropriate.
|
||||
pub fn get(&self) -> JSVal {
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
unsafe { (*self.val.get()).get() }
|
||||
}
|
||||
|
||||
/// Get the underlying unsafe pointer to the contained value.
|
||||
pub unsafe fn get_unsafe(&self) -> *mut JSVal {
|
||||
debug_assert!(thread_state::get().is_script());
|
||||
(*self.val.get()).get_unsafe()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// A holder that provides interior mutability for GC-managed values such as
|
||||
/// `JS<T>`. Essentially a `Cell<JS<T>>`, but safer.
|
||||
///
|
||||
|
|
|
@ -7,14 +7,14 @@ use dom::bindings::codegen::Bindings::CustomEventBinding::CustomEventMethods;
|
|||
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{MutHeapJSVal, Root};
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::bindings::trace::RootedTraceableBox;
|
||||
use dom::event::Event;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::{HandleValue, JSContext};
|
||||
use js::jsapi::{Heap, HandleValue, JSContext};
|
||||
use js::jsval::JSVal;
|
||||
use servo_atoms::Atom;
|
||||
|
||||
|
@ -23,14 +23,14 @@ use servo_atoms::Atom;
|
|||
pub struct CustomEvent {
|
||||
event: Event,
|
||||
#[ignore_heap_size_of = "Defined in rust-mozjs"]
|
||||
detail: MutHeapJSVal,
|
||||
detail: Heap<JSVal>,
|
||||
}
|
||||
|
||||
impl CustomEvent {
|
||||
fn new_inherited() -> CustomEvent {
|
||||
CustomEvent {
|
||||
event: Event::new_inherited(),
|
||||
detail: MutHeapJSVal::new(),
|
||||
detail: Heap::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,14 +8,14 @@ use dom::bindings::codegen::Bindings::ErrorEventBinding::ErrorEventMethods;
|
|||
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{MutHeapJSVal, Root};
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::bindings::trace::RootedTraceableBox;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::{HandleValue, JSContext};
|
||||
use js::jsapi::{Heap, HandleValue, JSContext};
|
||||
use js::jsval::JSVal;
|
||||
use servo_atoms::Atom;
|
||||
use std::cell::Cell;
|
||||
|
@ -28,7 +28,7 @@ pub struct ErrorEvent {
|
|||
lineno: Cell<u32>,
|
||||
colno: Cell<u32>,
|
||||
#[ignore_heap_size_of = "Defined in rust-mozjs"]
|
||||
error: MutHeapJSVal,
|
||||
error: Heap<JSVal>,
|
||||
}
|
||||
|
||||
impl ErrorEvent {
|
||||
|
@ -39,7 +39,7 @@ impl ErrorEvent {
|
|||
filename: DOMRefCell::new(DOMString::new()),
|
||||
lineno: Cell::new(0),
|
||||
colno: Cell::new(0),
|
||||
error: MutHeapJSVal::new()
|
||||
error: Heap::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,14 +7,14 @@ use dom::bindings::codegen::Bindings::PopStateEventBinding;
|
|||
use dom::bindings::codegen::Bindings::PopStateEventBinding::PopStateEventMethods;
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{MutHeapJSVal, Root};
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::bindings::trace::RootedTraceableBox;
|
||||
use dom::event::Event;
|
||||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::{HandleValue, JSContext};
|
||||
use js::jsapi::{Heap, HandleValue, JSContext};
|
||||
use js::jsval::JSVal;
|
||||
use servo_atoms::Atom;
|
||||
|
||||
|
@ -23,14 +23,14 @@ use servo_atoms::Atom;
|
|||
pub struct PopStateEvent {
|
||||
event: Event,
|
||||
#[ignore_heap_size_of = "Defined in rust-mozjs"]
|
||||
state: MutHeapJSVal,
|
||||
state: Heap<JSVal>,
|
||||
}
|
||||
|
||||
impl PopStateEvent {
|
||||
fn new_inherited() -> PopStateEvent {
|
||||
PopStateEvent {
|
||||
event: Event::new_inherited(),
|
||||
state: MutHeapJSVal::new(),
|
||||
state: Heap::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ use dom::bindings::callback::CallbackContainer;
|
|||
use dom::bindings::codegen::Bindings::PromiseBinding::AnyCallback;
|
||||
use dom::bindings::conversions::root_from_object;
|
||||
use dom::bindings::error::{Error, Fallible};
|
||||
use dom::bindings::js::MutHeapJSVal;
|
||||
use dom::bindings::reflector::{DomObject, MutDomObject, Reflector};
|
||||
use dom::globalscope::GlobalScope;
|
||||
use dom::promisenativehandler::PromiseNativeHandler;
|
||||
|
@ -27,6 +26,7 @@ use js::jsapi::{JSContext, HandleValue, HandleObject, IsPromiseObject, GetFuncti
|
|||
use js::jsapi::{JS_ClearPendingException, JSObject, AddRawValueRoot, RemoveRawValueRoot, PromiseState};
|
||||
use js::jsapi::{MutableHandleObject, NewPromiseObject, ResolvePromise, RejectPromise, GetPromiseState};
|
||||
use js::jsapi::{SetFunctionNativeReserved, NewFunctionWithReserved, AddPromiseReactions};
|
||||
use js::jsapi::Heap;
|
||||
use js::jsval::{JSVal, UndefinedValue, ObjectValue, Int32Value};
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
|
@ -39,7 +39,7 @@ pub struct Promise {
|
|||
/// native instance exists. This ensures that the reflector will never be GCed
|
||||
/// while native code could still interact with its native representation.
|
||||
#[ignore_heap_size_of = "SM handles JS values"]
|
||||
permanent_js_root: MutHeapJSVal,
|
||||
permanent_js_root: Heap<JSVal>,
|
||||
}
|
||||
|
||||
/// Private helper to enable adding new methods to Rc<Promise>.
|
||||
|
@ -93,7 +93,7 @@ impl Promise {
|
|||
assert!(IsPromiseObject(obj));
|
||||
let promise = Promise {
|
||||
reflector: Reflector::new(),
|
||||
permanent_js_root: MutHeapJSVal::new(),
|
||||
permanent_js_root: Heap::default(),
|
||||
};
|
||||
let mut promise = Rc::new(promise);
|
||||
Rc::get_mut(&mut promise).unwrap().init_reflector(obj.get());
|
||||
|
|
|
@ -15,7 +15,7 @@ use dom::bindings::codegen::UnionTypes::DocumentOrBodyInit;
|
|||
use dom::bindings::conversions::ToJSValConvertible;
|
||||
use dom::bindings::error::{Error, ErrorResult, Fallible};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{JS, MutHeapJSVal, MutNullableJS, Root};
|
||||
use dom::bindings::js::{JS, MutNullableJS, Root};
|
||||
use dom::bindings::refcounted::Trusted;
|
||||
use dom::bindings::reflector::{DomObject, reflect_dom_object};
|
||||
use dom::bindings::str::{ByteString, DOMString, USVString, is_token};
|
||||
|
@ -50,7 +50,7 @@ use hyper::mime::{self, Attr as MimeAttr, Mime, Value as MimeValue};
|
|||
use hyper_serde::Serde;
|
||||
use ipc_channel::ipc;
|
||||
use ipc_channel::router::ROUTER;
|
||||
use js::jsapi::{JSContext, JS_ParseJSON};
|
||||
use js::jsapi::{Heap, JSContext, JS_ParseJSON};
|
||||
use js::jsapi::JS_ClearPendingException;
|
||||
use js::jsval::{JSVal, NullValue, UndefinedValue};
|
||||
use net_traits::{FetchMetadata, FilteredMetadata};
|
||||
|
@ -133,7 +133,7 @@ pub struct XMLHttpRequest {
|
|||
response_xml: MutNullableJS<Document>,
|
||||
response_blob: MutNullableJS<Blob>,
|
||||
#[ignore_heap_size_of = "Defined in rust-mozjs"]
|
||||
response_json: MutHeapJSVal,
|
||||
response_json: Heap<JSVal>,
|
||||
#[ignore_heap_size_of = "Defined in hyper"]
|
||||
response_headers: DOMRefCell<Headers>,
|
||||
#[ignore_heap_size_of = "Defined in hyper"]
|
||||
|
@ -183,7 +183,7 @@ impl XMLHttpRequest {
|
|||
response_type: Cell::new(XMLHttpRequestResponseType::_empty),
|
||||
response_xml: Default::default(),
|
||||
response_blob: Default::default(),
|
||||
response_json: MutHeapJSVal::new(),
|
||||
response_json: Heap::default(),
|
||||
response_headers: DOMRefCell::new(Headers::new()),
|
||||
override_mime_type: DOMRefCell::new(None),
|
||||
override_charset: DOMRefCell::new(None),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue