Skip to content
Permalink
Browse files

Update to SpiderMonkey 66.

  • Loading branch information...
jdm committed May 6, 2019
1 parent d0d3401 commit 4328713f71d5bc389ecd47e78bfe9b8087b8c104
Showing with 150 additions and 144 deletions.
  1. +8 −8 Cargo.lock
  2. +1 −1 components/script/Cargo.toml
  3. +3 −3 components/script/compartments.rs
  4. +2 −2 components/script/devtools.rs
  5. +2 −2 components/script/dom/audiobuffer.rs
  6. +6 −6 components/script/dom/bindings/callback.rs
  7. +18 −19 components/script/dom/bindings/codegen/CodegenRust.py
  8. +2 −2 components/script/dom/bindings/htmlconstructor.rs
  9. +13 −15 components/script/dom/bindings/interface.rs
  10. +11 −2 components/script/dom/bindings/structuredclone.rs
  11. +6 −7 components/script/dom/bindings/utils.rs
  12. +1 −1 components/script/dom/bluetooth.rs
  13. +3 −5 components/script/dom/create.rs
  14. +8 −8 components/script/dom/customelementregistry.rs
  15. +2 −3 components/script/dom/dedicatedworkerglobalscope.rs
  16. +2 −2 components/script/dom/eventsource.rs
  17. +11 −6 components/script/dom/eventtarget.rs
  18. +2 −3 components/script/dom/filereader.rs
  19. +7 −8 components/script/dom/globalscope.rs
  20. +2 −2 components/script/dom/paintworkletglobalscope.rs
  21. +7 −7 components/script/dom/promise.rs
  22. +2 −3 components/script/dom/serviceworkerglobalscope.rs
  23. +2 −2 components/script/dom/websocket.rs
  24. +4 −4 components/script/dom/window.rs
  25. +4 −4 components/script/dom/windowproxy.rs
  26. +2 −2 components/script/dom/worker.rs
  27. +2 −2 components/script/dom/workerglobalscope.rs
  28. +2 −2 components/script/dom/worklet.rs
  29. +4 −4 components/script/fetch.rs
  30. +8 −6 components/script/script_runtime.rs
  31. +3 −3 components/script/script_thread.rs

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -65,7 +65,7 @@ indexmap = "1.0.2"
ipc-channel = "0.11"
itertools = "0.8"
jstraceable_derive = {path = "../jstraceable_derive"}
js = {package = "mozjs", version = "0.10.1"}
js = {package = "mozjs", git = "https://github.com/servo/rust-mozjs", rev = "357d1db91e4e49c3f148fe05fdfae5f8f0834ca8"}
keyboard-types = "0.4.4"
lazy_static = "1"
libc = "0.2"
@@ -3,7 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use crate::dom::globalscope::GlobalScope;
use js::jsapi::{GetCurrentRealmOrNull, JSAutoCompartment};
use js::jsapi::{GetCurrentRealmOrNull, JSAutoRealm};

pub struct AlreadyInCompartment(());

@@ -20,15 +20,15 @@ impl AlreadyInCompartment {
#[derive(Clone, Copy)]
pub enum InCompartment<'a> {
Already(&'a AlreadyInCompartment),
Entered(&'a JSAutoCompartment),
Entered(&'a JSAutoRealm),
}

impl<'a> InCompartment<'a> {
pub fn in_compartment(token: &AlreadyInCompartment) -> InCompartment {
InCompartment::Already(token)
}

pub fn entered(token: &JSAutoCompartment) -> InCompartment {
pub fn entered(token: &JSAutoRealm) -> InCompartment {
InCompartment::Entered(token)
}
}
@@ -23,7 +23,7 @@ use devtools_traits::{AutoMargins, CachedConsoleMessage, CachedConsoleMessageTyp
use devtools_traits::{ComputedNodeLayout, ConsoleAPI, PageError};
use devtools_traits::{EvaluateJSReply, Modification, NodeInfo, TimelineMarker};
use ipc_channel::ipc::IpcSender;
use js::jsapi::JSAutoCompartment;
use js::jsapi::JSAutoRealm;
use js::jsval::UndefinedValue;
use js::rust::wrappers::ObjectClassName;
use msg::constellation_msg::PipelineId;
@@ -37,7 +37,7 @@ pub fn handle_evaluate_js(global: &GlobalScope, eval: String, reply: IpcSender<E
let result = unsafe {
let cx = global.get_cx();
let globalhandle = global.reflector().get_jsobject();
let _ac = JSAutoCompartment::new(cx, globalhandle.get());
let _ac = JSAutoRealm::new(cx, globalhandle.get());
rooted!(in(cx) let mut rval = UndefinedValue());
global.evaluate_js_on_global_with_result(&eval, rval.handle_mut());

@@ -14,7 +14,7 @@ use crate::dom::bindings::root::DomRoot;
use crate::dom::window::Window;
use dom_struct::dom_struct;
use js::jsapi::JS_GetArrayBufferViewBuffer;
use js::jsapi::{Heap, JSAutoCompartment, JSContext, JSObject};
use js::jsapi::{Heap, JSAutoRealm, JSContext, JSObject};
use js::rust::wrappers::JS_DetachArrayBuffer;
use js::rust::CustomAutoRooterGuard;
use js::typedarray::{CreateWith, Float32Array};
@@ -127,7 +127,7 @@ impl AudioBuffer {
#[allow(unsafe_code)]
unsafe fn restore_js_channel_data(&self, cx: *mut JSContext) -> bool {
let global = self.global();
let _ac = JSAutoCompartment::new(cx, global.reflector().get_jsobject().get());
let _ac = JSAutoRealm::new(cx, global.reflector().get_jsobject().get());
for (i, channel) in self.js_channels.borrow_mut().iter().enumerate() {
if !channel.get().is_null() {
// Already have data in JS array.
@@ -14,9 +14,9 @@ use crate::dom::bindings::utils::AsCCharPtrPtr;
use crate::dom::globalscope::GlobalScope;
use crate::dom::window::Window;
use js::jsapi::Heap;
use js::jsapi::JSAutoCompartment;
use js::jsapi::JSAutoRealm;
use js::jsapi::{AddRawValueRoot, IsCallable, JSContext, JSObject};
use js::jsapi::{JSCompartment, JS_EnterCompartment, JS_LeaveCompartment, RemoveRawValueRoot};
use js::jsapi::{EnterRealm, LeaveRealm, Realm, RemoveRawValueRoot};
use js::jsval::{JSVal, ObjectValue, UndefinedValue};
use js::rust::wrappers::{JS_GetProperty, JS_WrapObject};
use js::rust::{MutableHandleObject, Runtime};
@@ -229,7 +229,7 @@ pub struct CallSetup {
/// The `JSContext` used for the call.
cx: *mut JSContext,
/// The compartment we were in before the call.
old_compartment: *mut JSCompartment,
old_realm: *mut Realm,
/// The exception handling used for the call.
handling: ExceptionHandling,
/// <https://heycam.github.io/webidl/#es-invoking-callback-functions>
@@ -255,7 +255,7 @@ impl CallSetup {
CallSetup {
exception_global: global,
cx: cx,
old_compartment: unsafe { JS_EnterCompartment(cx, callback.callback()) },
old_realm: unsafe { EnterRealm(cx, callback.callback()) },
handling: handling,
entry_script: Some(aes),
incumbent_script: ais,
@@ -271,9 +271,9 @@ impl CallSetup {
impl Drop for CallSetup {
fn drop(&mut self) {
unsafe {
JS_LeaveCompartment(self.cx, self.old_compartment);
LeaveRealm(self.cx, self.old_realm);
if self.handling == ExceptionHandling::Report {
let _ac = JSAutoCompartment::new(
let _ac = JSAutoRealm::new(
self.cx,
self.exception_global.reflector().get_jsobject().get(),
);
@@ -458,7 +458,7 @@ def pickFirstSignature(condition, filterLambda):
pickFirstSignature("%s.get().is_object() && "
"{ rooted!(in(cx) let obj = %s.get().to_object()); "
"let mut is_date = false; "
"assert!(JS_ObjectIsDate(cx, obj.handle(), &mut is_date)); "
"assert!(ObjectIsDate(cx, obj.handle(), &mut is_date)); "
"is_date }" %
(distinguishingArg, distinguishingArg),
lambda s: (s[1][distinguishingIndex].type.isDate() or
@@ -795,7 +795,7 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type,
# our own implementation code.
templateBody = fill(
"""
{ // Scope for our JSAutoCompartment.
{ // Scope for our JSAutoRealm.
rooted!(in(cx) let globalObj = CurrentGlobalOrNull(cx));
let promiseGlobal = GlobalScope::from_object_maybe_wrapped(globalObj.handle().get());
@@ -2709,7 +2709,7 @@ def definition_body(self):
assert!(((*get_object_class(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
rooted!(in(cx) let mut proto = ptr::null_mut::<JSObject>());
let _ac = JSAutoCompartment::new(cx, scope.get());
let _ac = JSAutoRealm::new(cx, scope.get());
GetProtoObject(cx, scope, proto.handle_mut());
assert!(!proto.is_null());
@@ -2764,7 +2764,7 @@ def definition_body(self):
(*raw).init_reflector(obj.get());
let _ac = JSAutoCompartment::new(cx, obj.get());
let _ac = JSAutoRealm::new(cx, obj.get());
rooted!(in(cx) let mut proto = ptr::null_mut::<JSObject>());
GetProtoObject(cx, obj.handle(), proto.handle_mut());
assert!(JS_SplicePrototype(cx, obj.handle(), proto.handle()));
@@ -2883,7 +2883,7 @@ def definition_body(self):
name = self.descriptor.interface.identifier.name
if self.descriptor.interface.isNamespace():
if self.descriptor.interface.getExtendedAttribute("ProtoObjectHack"):
proto = "JS_GetObjectPrototype(cx, global)"
proto = "GetRealmObjectPrototype(cx)"
else:
proto = "JS_NewPlainObject(cx)"
if self.properties.static_methods.length():
@@ -2919,11 +2919,12 @@ def definition_body(self):
parentName = self.descriptor.getParentName()
if not parentName:
if self.descriptor.interface.getExtendedAttribute("ExceptionClass"):
getPrototypeProto = "prototype_proto.set(JS_GetErrorPrototype(cx))"
protoGetter = "GetRealmErrorPrototype"
elif self.descriptor.interface.isIteratorInterface():
getPrototypeProto = "prototype_proto.set(JS_GetIteratorPrototype(cx))"
protoGetter = "GetRealmIteratorPrototype"
else:
getPrototypeProto = "prototype_proto.set(JS_GetObjectPrototype(cx, global))"
protoGetter = "GetRealmObjectPrototype"
getPrototypeProto = "prototype_proto.set(%s(cx))" % protoGetter
else:
getPrototypeProto = ("%s::GetProtoObject(cx, global, prototype_proto.handle_mut())" %
toBindingNamespace(parentName))
@@ -2981,14 +2982,13 @@ def definition_body(self):
else:
properties["length"] = 0
parentName = self.descriptor.getParentName()
code.append(CGGeneric("rooted!(in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());"))
if parentName:
parentName = toBindingNamespace(parentName)
code.append(CGGeneric("""
rooted!(in(cx) let mut interface_proto = ptr::null_mut::<JSObject>());
%s::GetConstructorObject(cx, global, interface_proto.handle_mut());""" % parentName))
else:
code.append(CGGeneric("""
rooted!(in(cx) let interface_proto = JS_GetFunctionPrototype(cx, global));"""))
code.append(CGGeneric("interface_proto.set(GetRealmFunctionPrototype(cx));"))
code.append(CGGeneric("""\
assert!(!interface_proto.is_null());
@@ -5544,7 +5544,7 @@ def definition_body(self):
rooted!(in(cx) let mut prototype = ptr::null_mut::<JSObject>());
{
rooted!(in(cx) let mut proto_val = UndefinedValue());
let _ac = JSAutoCompartment::new(cx, new_target.get());
let _ac = JSAutoRealm::new(cx, new_target.get());
if !JS_GetProperty(cx, new_target.handle(), b"prototype\\0".as_ptr() as *const _, proto_val.handle_mut()) {
return false;
}
@@ -5765,7 +5765,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
'js::jsapi::Heap',
'js::jsapi::INTERNED_STRING_TO_JSID',
'js::jsapi::IsCallable',
'js::jsapi::JSAutoCompartment',
'js::jsapi::JSAutoRealm',
'js::jsapi::JSCLASS_FOREGROUND_FINALIZE',
'js::jsapi::JSCLASS_RESERVED_SLOTS_SHIFT',
'js::jsapi::JSClass',
@@ -5804,11 +5804,10 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
'js::rust::wrappers::JS_DefineProperty',
'js::rust::wrappers::JS_DefinePropertyById2',
'js::jsapi::JS_ForwardGetPropertyTo',
'js::jsapi::JS_GetErrorPrototype',
'js::rust::wrappers::JS_GetFunctionPrototype',
'js::jsapi::JS_GetGlobalForObject',
'js::jsapi::JS_GetIteratorPrototype',
'js::rust::wrappers::JS_GetObjectPrototype',
'js::jsapi::GetRealmErrorPrototype',
'js::jsapi::GetRealmFunctionPrototype',
'js::jsapi::GetRealmIteratorPrototype',
'js::jsapi::GetRealmObjectPrototype',
'js::rust::wrappers::JS_GetProperty',
'js::jsapi::JS_GetPropertyById',
'js::jsapi::JS_GetPropertyDescriptorById',
@@ -5819,7 +5818,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
'js::jsapi::JS_NewObject',
'js::rust::wrappers::JS_NewObjectWithGivenProto',
'js::rust::wrappers::JS_NewObjectWithoutMetadata',
'js::rust::wrappers::JS_ObjectIsDate',
'js::rust::wrappers::ObjectIsDate',
'js::rust::wrappers::JS_SetImmutablePrototype',
'js::rust::wrappers::JS_SetProperty',
'js::rust::wrappers::JS_SetPrototype',
@@ -81,7 +81,7 @@ use html5ever::interface::QualName;
use html5ever::LocalName;
use js::glue::UnwrapObject;
use js::jsapi::{CallArgs, CurrentGlobalOrNull};
use js::jsapi::{JSAutoCompartment, JSContext, JSObject};
use js::jsapi::{JSAutoRealm, JSContext, JSObject};
use js::rust::HandleObject;
use js::rust::MutableHandleObject;
use std::ptr;
@@ -115,7 +115,7 @@ where
}

{
let _ac = JSAutoCompartment::new(window.get_cx(), callee.get());
let _ac = JSAutoRealm::new(window.get_cx(), callee.get());
rooted!(in(window.get_cx()) let mut constructor = ptr::null_mut::<JSObject>());
rooted!(in(window.get_cx()) let global_object = CurrentGlobalOrNull(window.get_cx()));

@@ -16,11 +16,9 @@ use js::error::throw_type_error;
use js::glue::{UncheckedUnwrapObject, RUST_SYMBOL_TO_JSID};
use js::jsapi::HandleObject as RawHandleObject;
use js::jsapi::MutableHandleValue as RawMutableHandleValue;
use js::jsapi::{Class, ClassOps, CompartmentOptions};
use js::jsapi::{GetGlobalForObjectCrossCompartment, GetWellKnownSymbol};
use js::jsapi::{
JSAutoCompartment, JSClass, JSContext, JSFunctionSpec, JSObject, JSFUN_CONSTRUCTOR,
};
use js::jsapi::{Class, ClassOps, RealmOptions};
use js::jsapi::{GetNonCCWObjectGlobal, GetWellKnownSymbol};
use js::jsapi::{JSAutoRealm, JSClass, JSContext, JSFunctionSpec, JSObject, JSFUN_CONSTRUCTOR};
use js::jsapi::{JSPropertySpec, JSString, JSTracer, JS_AtomizeAndPinString};
use js::jsapi::{JS_GetFunctionObject, JS_NewFunction, JS_NewGlobalObject};
use js::jsapi::{JS_NewObject, JS_NewPlainObject};
@@ -29,8 +27,8 @@ use js::jsapi::{ObjectOps, OnNewGlobalHookOption, SymbolCode};
use js::jsapi::{TrueHandleValue, Value};
use js::jsapi::{JSPROP_PERMANENT, JSPROP_READONLY, JSPROP_RESOLVING};
use js::jsval::{JSVal, PrivateValue};
use js::rust::wrappers::{JS_DefineProperty, JS_DefineProperty2};
use js::rust::wrappers::{JS_DefineProperty3, JS_DefineProperty4, JS_DefinePropertyById4};
use js::rust::wrappers::{JS_DefineProperty, JS_DefineProperty5};
use js::rust::wrappers::{JS_DefineProperty3, JS_DefineProperty4, JS_DefinePropertyById5};
use js::rust::wrappers::{JS_FireOnNewGlobalObject, JS_GetPrototype};
use js::rust::wrappers::{JS_LinkConstructorAndPrototype, JS_NewObjectWithUniqueType};
use js::rust::{define_methods, define_properties, get_object_class};
@@ -138,7 +136,7 @@ pub unsafe fn create_global_object(
) {
assert!(rval.is_null());

let mut options = CompartmentOptions::default();
let mut options = RealmOptions::default();
options.creationOptions_.traceGlobal_ = Some(trace);
options.creationOptions_.sharedMemoryAndAtomics_ = true;

@@ -160,7 +158,7 @@ pub unsafe fn create_global_object(
let val = PrivateValue(Box::into_raw(proto_array) as *const libc::c_void);
JS_SetReservedSlot(rval.get(), DOM_PROTOTYPE_SLOT, &val);

let _ac = JSAutoCompartment::new(cx, rval.get());
let _ac = JSAutoRealm::new(cx, rval.get());
JS_FireOnNewGlobalObject(cx, rval.handle());
}

@@ -209,7 +207,7 @@ pub unsafe fn create_interface_prototype_object(
assert!(!unscopable_symbol.is_null());

rooted!(in(cx) let unscopable_id = RUST_SYMBOL_TO_JSID(unscopable_symbol));
assert!(JS_DefinePropertyById4(
assert!(JS_DefinePropertyById5(
cx,
rval.handle(),
unscopable_id.handle(),
@@ -275,7 +273,7 @@ pub unsafe fn create_named_constructors(
constructor.set(JS_GetFunctionObject(fun));
assert!(!constructor.is_null());

assert!(JS_DefineProperty2(
assert!(JS_DefineProperty3(
cx,
constructor.handle(),
b"prototype\0".as_ptr() as *const libc::c_char,
@@ -360,7 +358,7 @@ pub unsafe fn define_on_global_object(
obj: HandleObject,
) {
assert_eq!(*name.last().unwrap(), b'\0');
assert!(JS_DefineProperty2(
assert!(JS_DefineProperty3(
cx,
global,
name.as_ptr() as *const libc::c_char,
@@ -442,7 +440,7 @@ unsafe fn has_instance(
}

// Step 2.
let global = GetGlobalForObjectCrossCompartment(interface_object.get());
let global = GetNonCCWObjectGlobal(interface_object.get());
assert!(!global.is_null());
let proto_or_iface_array = get_proto_or_iface_array(global);
rooted!(in(cx) let prototype = (*proto_or_iface_array)[object_class.proto_id as usize]);
@@ -488,7 +486,7 @@ unsafe fn define_name(cx: *mut JSContext, obj: HandleObject, name: &[u8]) {
assert_eq!(*name.last().unwrap(), b'\0');
rooted!(in(cx) let name = JS_AtomizeAndPinString(cx, name.as_ptr() as *const libc::c_char));
assert!(!name.is_null());
assert!(JS_DefineProperty3(
assert!(JS_DefineProperty4(
cx,
obj,
b"name\0".as_ptr() as *const libc::c_char,
@@ -498,7 +496,7 @@ unsafe fn define_name(cx: *mut JSContext, obj: HandleObject, name: &[u8]) {
}

unsafe fn define_length(cx: *mut JSContext, obj: HandleObject, length: i32) {
assert!(JS_DefineProperty4(
assert!(JS_DefineProperty5(
cx,
obj,
b"length\0".as_ptr() as *const libc::c_char,
Oops, something went wrong.

0 comments on commit 4328713

Please sign in to comment.
You can’t perform that action at this time.