Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SpiderMonkey #10756

Merged
merged 1 commit into from May 3, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -14,10 +14,6 @@

DOMInterfaces = {

'Window': {
'outerObjectHook': 'Some(bindings::utils::outerize_global)',
},

'Range': {
'weakReferenceable': True,
},

Large diffs are not rendered by default.

@@ -281,7 +281,7 @@ pub unsafe fn private_from_proto_check<F>(mut obj: *mut JSObject,
let dom_class = try!(get_dom_class(obj).or_else(|_| {
if IsWrapper(obj) {
debug!("found wrapper");
obj = UnwrapObject(obj, /* stopAtOuter = */ 0);
obj = UnwrapObject(obj, /* stopAtWindowProxy = */ 0);
if obj.is_null() {
debug!("unwrapping security wrapper failed");
Err(())
@@ -424,7 +424,9 @@ unsafe impl ArrayBufferViewContents for f64 {
pub unsafe fn array_buffer_view_data<'a, T: ArrayBufferViewContents>(abv: *mut JSObject) -> Option<&'a mut [T]> {
let mut byte_length = 0;
let mut ptr = ptr::null_mut();
let ret = JS_GetObjectAsArrayBufferView(abv, &mut byte_length, &mut ptr);
let mut is_shared = false;
let ret = JS_GetObjectAsArrayBufferView(abv, &mut byte_length, &mut is_shared, &mut ptr);
assert!(!is_shared);
if ret.is_null() {
return None;
}
@@ -463,5 +465,7 @@ pub fn array_buffer_view_to_vec_checked<T: ArrayBufferViewContents>(abv: *mut JS
/// Note: Currently only Arrays are supported.
/// TODO: Expand this to support sequences and other array-like objects
pub unsafe fn is_array_like(cx: *mut JSContext, value: HandleValue) -> bool {
JS_IsArrayObject(cx, value)
let mut result = false;
assert!(JS_IsArrayObject(cx, value, &mut result));
result
}
@@ -11,15 +11,15 @@ use js::error::throw_type_error;
use js::glue::UncheckedUnwrapObject;
use js::jsapi::{Class, ClassExtension, ClassSpec, GetGlobalForObjectCrossCompartment};
use js::jsapi::{HandleObject, HandleValue, JSClass, JSContext, JSFunctionSpec};
use js::jsapi::{JSNative, JSPropertySpec, JSString, JS_DefineProperty1, JS_DefineProperty2};
use js::jsapi::{JS_DefineProperty4, JS_GetClass, JS_GetFunctionObject, JS_GetPrototype};
use js::jsapi::{JS_InternString, JS_LinkConstructorAndPrototype, JS_NewFunction, JS_NewObject};
use js::jsapi::{JSNative, JSFUN_CONSTRUCTOR, JSPROP_ENUMERATE, JSPROP_PERMANENT, JSPROP_READONLY};
use js::jsapi::{JSPROP_RESOLVING, JSPropertySpec, JSString, JS_DefineProperty1, JS_DefineProperty2};
use js::jsapi::{JS_AtomizeAndPinString, JS_DefineProperty4, JS_GetClass, JS_GetFunctionObject};
use js::jsapi::{JS_GetPrototype, JS_LinkConstructorAndPrototype, JS_NewFunction, JS_NewObject};
use js::jsapi::{JS_NewObjectWithUniqueType, JS_NewStringCopyZ, JS_DefineProperty};
use js::jsapi::{MutableHandleObject, MutableHandleValue, ObjectOps, RootedObject, RootedString};
use js::jsapi::{RootedValue, Value};
use js::jsval::{BooleanValue, DoubleValue, Int32Value, JSVal, NullValue, UInt32Value};
use js::rust::{define_methods, define_properties};
use js::{JSPROP_ENUMERATE, JSFUN_CONSTRUCTOR, JSPROP_PERMANENT, JSPROP_READONLY};
use libc;
use std::ptr;

@@ -127,25 +127,23 @@ impl NonCallbackInterfaceObjectClass {
setProperty: None,
enumerate: None,
resolve: None,
convert: None,
mayResolve: None,
finalize: None,
call: constructor_behavior.call,
construct: constructor_behavior.construct,
hasInstance: Some(has_instance_hook),
trace: None,
spec: ClassSpec {
createConstructor: None,
createPrototype: None,
constructorFunctions: ptr::null(),
constructorProperties: ptr::null(),
prototypeFunctions: ptr::null(),
prototypeProperties: ptr::null(),
finishInit: None,
createConstructor_: None,
createPrototype_: None,
constructorFunctions_: ptr::null(),
constructorProperties_: ptr::null(),
prototypeFunctions_: ptr::null(),
prototypeProperties_: ptr::null(),
finishInit_: None,
flags: 0,
},
ext: ClassExtension {
outerObject: None,
innerObject: None,
isWrappedNative: false,
weakmapKeyDelegateOp: None,
objectMovedOp: None,
@@ -162,7 +160,6 @@ impl NonCallbackInterfaceObjectClass {
unwatch: None,
getElements: None,
enumerate: None,
thisObject: None,
funToString: Some(fun_to_string_hook),
}
},
@@ -323,7 +320,7 @@ unsafe fn has_instance(
let js_class = JS_GetClass(interface_object.get());
let object_class = &*(js_class as *const NonCallbackInterfaceObjectClass);

if let Ok(dom_class) = get_dom_class(UncheckedUnwrapObject(value.ptr, /* stopAtOuter = */ 0)) {
if let Ok(dom_class) = get_dom_class(UncheckedUnwrapObject(value.ptr, /* stopAtWindowProxy = */ 0)) {
if dom_class.interface_chain[object_class.proto_depth as usize] == object_class.proto_id {
// Step 4.
return Ok(true);
@@ -372,8 +369,8 @@ unsafe fn create_object(

unsafe fn define_name(cx: *mut JSContext, obj: HandleObject, name: &'static [u8]) {
assert!(*name.last().unwrap() == b'\0');
let name =
RootedString::new(cx, JS_InternString(cx, name.as_ptr() as *const libc::c_char));
let name = RootedString::new(
cx, JS_AtomizeAndPinString(cx, name.as_ptr() as *const libc::c_char));
assert!(!name.ptr.is_null());
assert!(JS_DefineProperty2(cx,
obj,
@@ -402,7 +399,7 @@ unsafe fn define_on_global_object(
receiver,
name.as_ptr() as *const libc::c_char,
obj,
0,
JSPROP_RESOLVING,
None, None));
}

@@ -8,16 +8,15 @@

use dom::bindings::conversions::is_dom_proxy;
use dom::bindings::utils::delete_property_by_id;
use js::JSPROP_GETTER;
use js::glue::GetProxyExtra;
use js::glue::InvokeGetOwnPropertyDescriptor;
use js::glue::{GetProxyHandler, SetProxyExtra};
use js::jsapi::GetObjectProto;
use js::jsapi::JS_GetPropertyDescriptorById;
use js::jsapi::{Handle, HandleId, HandleObject, MutableHandle, ObjectOpResult, RootedObject};
use js::jsapi::{JSContext, JSObject, JSPropertyDescriptor};
use js::jsapi::{JSContext, JSObject, JSPROP_GETTER, PropertyDescriptor};
use js::jsapi::{JSErrNum, JS_StrictPropertyStub};
use js::jsapi::{JS_DefinePropertyById6, JS_NewObjectWithGivenProto};
use js::jsapi::{JS_DefinePropertyById, JS_NewObjectWithGivenProto};
use js::jsval::ObjectValue;
use libc;
use std::{mem, ptr};
@@ -31,7 +30,7 @@ static JSPROXYSLOT_EXPANDO: u32 = 0;
pub unsafe extern "C" fn get_property_descriptor(cx: *mut JSContext,
proxy: HandleObject,
id: HandleId,
desc: MutableHandle<JSPropertyDescriptor>)
desc: MutableHandle<PropertyDescriptor>)
-> bool {
let handler = GetProxyHandler(proxy.get());
if !InvokeGetOwnPropertyDescriptor(handler, cx, proxy, id, desc) {
@@ -54,7 +53,7 @@ pub unsafe extern "C" fn get_property_descriptor(cx: *mut JSContext,
pub unsafe extern "C" fn define_property(cx: *mut JSContext,
proxy: HandleObject,
id: HandleId,
desc: Handle<JSPropertyDescriptor>,
desc: Handle<PropertyDescriptor>,
result: *mut ObjectOpResult)
-> bool {
// FIXME: Workaround for https://github.com/rust-lang/rfcs/issues/718
@@ -67,7 +66,7 @@ pub unsafe extern "C" fn define_property(cx: *mut JSContext,
}

let expando = RootedObject::new(cx, ensure_expando_object(cx, proxy));
JS_DefinePropertyById6(cx, expando.handle(), id, desc, result)
JS_DefinePropertyById(cx, expando.handle(), id, desc, result)
}

/// Deletes an expando off the given `proxy`.
@@ -126,15 +125,15 @@ pub fn ensure_expando_object(cx: *mut JSContext, obj: HandleObject) -> *mut JSOb
expando = JS_NewObjectWithGivenProto(cx, ptr::null_mut(), HandleObject::null());
assert!(!expando.is_null());

SetProxyExtra(obj.get(), JSPROXYSLOT_EXPANDO, ObjectValue(&*expando));
SetProxyExtra(obj.get(), JSPROXYSLOT_EXPANDO, &ObjectValue(&*expando));
}
expando
}
}

/// Set the property descriptor's object to `obj` and set it to enumerable,
/// and writable if `readonly` is true.
pub fn fill_property_descriptor(desc: &mut JSPropertyDescriptor,
pub fn fill_property_descriptor(desc: &mut PropertyDescriptor,
obj: *mut JSObject,
attrs: u32) {
desc.obj = obj;
@@ -33,6 +33,7 @@ use std::cell::RefCell;
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::collections::hash_map::HashMap;
use std::marker::PhantomData;
use std::os;
use std::sync::{Arc, Mutex};


@@ -199,7 +200,7 @@ impl LiveDOMReferences {

/// A JSTraceDataOp for tracing reflectors held in LIVE_REFERENCES
pub unsafe extern "C" fn trace_refcounted_objects(tracer: *mut JSTracer,
_data: *mut libc::c_void) {
_data: *mut os::raw::c_void) {
LIVE_REFERENCES.with(|ref r| {
let r = r.borrow();
let live_references = r.as_ref().unwrap();
@@ -7,9 +7,8 @@

use dom::bindings::error::{Error, Fallible};
use dom::bindings::global::GlobalRef;
use js::glue::JS_STRUCTURED_CLONE_VERSION;
use js::jsapi::{HandleValue, MutableHandleValue};
use js::jsapi::{JSContext, JS_ReadStructuredClone};
use js::jsapi::{JSContext, JS_ReadStructuredClone, JS_STRUCTURED_CLONE_VERSION};
use js::jsapi::{JS_ClearPendingException, JS_WriteStructuredClone};
use libc::size_t;
use std::ptr;
@@ -49,8 +49,8 @@ use hyper::header::Headers;
use hyper::method::Method;
use hyper::mime::Mime;
use ipc_channel::ipc::{IpcReceiver, IpcSender};
use js::jsapi::JS_CallUnbarrieredObjectTracer;
use js::jsapi::{GCTraceKindToAscii, Heap, JSGCTraceKind, JSObject, JSTracer, JS_CallObjectTracer, JS_CallValueTracer};
use js::glue::{CallObjectTracer, CallUnbarrieredObjectTracer, CallValueTracer};
use js::jsapi::{GCTraceKindToAscii, Heap, TraceKind, JSObject, JSTracer};
use js::jsval::JSVal;
use js::rust::Runtime;
use layout_interface::{LayoutChan, LayoutRPC};
@@ -72,7 +72,6 @@ use smallvec::SmallVec;
use std::boxed::FnBox;
use std::cell::{Cell, UnsafeCell};
use std::collections::{BTreeMap, HashMap, HashSet};
use std::ffi::CString;
use std::hash::{BuildHasher, Hash};
use std::intrinsics::return_address;
use std::iter::{FromIterator, IntoIterator};
@@ -114,43 +113,31 @@ pub fn trace_jsval(tracer: *mut JSTracer, description: &str, val: &Heap<JSVal>)
return;
}

let name = CString::new(description).unwrap();
(*tracer).debugPrinter_ = None;
(*tracer).debugPrintIndex_ = !0;
(*tracer).debugPrintArg_ = name.as_ptr() as *const libc::c_void;
debug!("tracing value {}", description);
JS_CallValueTracer(tracer,
val.ptr.get() as *mut _,
GCTraceKindToAscii(val.get().trace_kind()));
CallValueTracer(tracer,
val.ptr.get() as *mut _,
GCTraceKindToAscii(val.get().trace_kind()));
}
}

/// Trace the `JSObject` held by `reflector`.
#[allow(unrooted_must_root)]
pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Reflector) {
unsafe {
let name = CString::new(description).unwrap();
(*tracer).debugPrinter_ = None;
(*tracer).debugPrintIndex_ = !0;
(*tracer).debugPrintArg_ = name.as_ptr() as *const libc::c_void;
debug!("tracing reflector {}", description);
JS_CallUnbarrieredObjectTracer(tracer,
reflector.rootable(),
GCTraceKindToAscii(JSGCTraceKind::JSTRACE_OBJECT));
CallUnbarrieredObjectTracer(tracer,
reflector.rootable(),
GCTraceKindToAscii(TraceKind::Object));
}
}

/// Trace a `JSObject`.
pub fn trace_object(tracer: *mut JSTracer, description: &str, obj: &Heap<*mut JSObject>) {
unsafe {
let name = CString::new(description).unwrap();
(*tracer).debugPrinter_ = None;
(*tracer).debugPrintIndex_ = !0;
(*tracer).debugPrintArg_ = name.as_ptr() as *const libc::c_void;
debug!("tracing {}", description);
JS_CallObjectTracer(tracer,
obj.ptr.get() as *mut _,
GCTraceKindToAscii(JSGCTraceKind::JSTRACE_OBJECT));
CallObjectTracer(tracer,
obj.ptr.get() as *mut _,
GCTraceKindToAscii(TraceKind::Object));
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.