Update to SpiderMonkey 66.

This commit is contained in:
Josh Matthews 2019-05-06 11:38:34 -04:00
parent d0d3401361
commit 4328713f71
31 changed files with 150 additions and 144 deletions

View file

@ -458,7 +458,7 @@ class CGMethodCall(CGThing):
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 getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
# 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 @@ assert!(!scope.get().is_null());
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 @@ assert!(!obj.is_null());
(*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 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
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 @@ assert!((*cache)[PrototypeList::Constructor::%(id)s as usize].is_null());
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 @@ assert!((*cache)[PrototypeList::ID::%(id)s as usize].is_null());
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 @@ if args.callee() == new_target.get() {
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',