mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Changes for spidermomkey upgrade.
This commit is contained in:
parent
f1bb3dcad0
commit
bd77a4043c
16 changed files with 245 additions and 186 deletions
79
Cargo.lock
generated
79
Cargo.lock
generated
|
@ -307,7 +307,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "0f8523b410d7187a43085e7e064416ea32ded16bd0a4e6fc025e21616d01258f"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cexpr",
|
||||
"cexpr 0.4.0",
|
||||
"clang-sys",
|
||||
"clap",
|
||||
"env_logger",
|
||||
|
@ -320,7 +320,28 @@ dependencies = [
|
|||
"regex",
|
||||
"rustc-hash",
|
||||
"shlex",
|
||||
"which",
|
||||
"which 3.1.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.62.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c6720a8b7b2d39dd533285ed438d458f65b31b5c257e6ac7bb3d7e82844dd722"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cexpr 0.6.0",
|
||||
"clang-sys",
|
||||
"lazy_static",
|
||||
"lazycell",
|
||||
"peeking_take_while",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"rustc-hash",
|
||||
"shlex",
|
||||
"syn",
|
||||
"which 4.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -679,6 +700,15 @@ dependencies = [
|
|||
"nom 5.1.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cexpr"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
||||
dependencies = [
|
||||
"nom 7.1.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
|
@ -3924,7 +3954,6 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "mozjs"
|
||||
version = "0.14.1"
|
||||
source = "git+https://github.com/servo/rust-mozjs#a10ab915532bb3e334e564364ed3630561bccacb"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"lazy_static",
|
||||
|
@ -3937,9 +3966,8 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "mozjs_sys"
|
||||
version = "0.68.2"
|
||||
source = "git+https://github.com/servo/mozjs?rev=72ce2c95d24b225e3c87364608822b498b2312fb#72ce2c95d24b225e3c87364608822b498b2312fb"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"bindgen 0.62.0",
|
||||
"cc",
|
||||
"encoding_c",
|
||||
"encoding_c_mem",
|
||||
|
@ -4932,11 +4960,11 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.37"
|
||||
version = "1.0.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1"
|
||||
checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -5209,9 +5237,9 @@ checksum = "2b5ceb840e4009da4841ed22a15eb49f64fdd00a2138945c5beacf506b2fb5ed"
|
|||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.4.5"
|
||||
version = "1.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19"
|
||||
checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
|
@ -5220,9 +5248,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.23"
|
||||
version = "0.6.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548"
|
||||
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
|
||||
|
||||
[[package]]
|
||||
name = "remove_dir_all"
|
||||
|
@ -6276,7 +6304,7 @@ dependencies = [
|
|||
"app_units",
|
||||
"arrayvec 0.7.1",
|
||||
"atomic_refcell",
|
||||
"bindgen",
|
||||
"bindgen 0.58.1",
|
||||
"bitflags",
|
||||
"byteorder",
|
||||
"cssparser",
|
||||
|
@ -6452,13 +6480,13 @@ checksum = "e454d048db5527d000bfddb77bd072bbf3a1e2ae785f16d9bd116e07c2ab45eb"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.67"
|
||||
version = "1.0.103"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6498a9efc342871f91cc2d0d694c674368b4ceb40f62b65a7a08c3792935e702"
|
||||
checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-xid",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -6939,6 +6967,12 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
version = "0.1.17"
|
||||
|
@ -7403,7 +7437,7 @@ version = "0.0.1"
|
|||
source = "git+https://github.com/servo/webxr#af2e84a28d52521212816584e0553aaf364a9162"
|
||||
dependencies = [
|
||||
"android_injected_glue",
|
||||
"bindgen",
|
||||
"bindgen 0.58.1",
|
||||
"crossbeam-channel 0.4.4",
|
||||
"euclid",
|
||||
"gl_generator 0.13.1",
|
||||
|
@ -7484,6 +7518,17 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b"
|
||||
dependencies = [
|
||||
"either",
|
||||
"libc",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
|
|
|
@ -34,6 +34,11 @@ winit = { git = "https://github.com/rust-windowing/winit.git", rev = "4192d04a53
|
|||
[patch."https://github.com/jrmuizel/raqote"]
|
||||
raqote = { git = "https://github.com/jdm/raqote", branch = "fkup" }
|
||||
|
||||
[patch."https://github.com/servo/mozjs"]
|
||||
mozjs_sys = { path = "../mozjs/mozjs" }
|
||||
[patch."https://github.com/servo/rust-mozjs"]
|
||||
mozjs = { path = "../mozjs/rust-mozjs" }
|
||||
|
||||
# https://github.com/servo/servo/issues/27515#issuecomment-671474054
|
||||
[patch."https://github.com/servo/webrender"]
|
||||
webrender = { git = "https://github.com/jdm/webrender", branch = "crash-backtrace" }
|
||||
|
|
|
@ -1886,7 +1886,7 @@ class AttrDefiner(PropertyDefiner):
|
|||
"name": m.identifier.name,
|
||||
"attr": m,
|
||||
"flags": "JSPROP_ENUMERATE",
|
||||
"is_accessor": "true",
|
||||
"kind": "JSPropertySpec_Kind::NativeAccessor",
|
||||
}
|
||||
for m in descriptor.interface.members if
|
||||
m.isAttr() and m.isStatic() == static
|
||||
|
@ -1906,7 +1906,7 @@ class AttrDefiner(PropertyDefiner):
|
|||
"name": "@@toStringTag",
|
||||
"attr": None,
|
||||
"flags": "JSPROP_READONLY",
|
||||
"is_accessor": "false",
|
||||
"kind": "JSPropertySpec_Kind::Value",
|
||||
})
|
||||
|
||||
def generateArray(self, array, name):
|
||||
|
@ -1963,13 +1963,13 @@ class AttrDefiner(PropertyDefiner):
|
|||
|
||||
def specData(attr):
|
||||
if attr["name"] == "@@toStringTag":
|
||||
return (attr["name"][2:], attr["flags"], attr["is_accessor"],
|
||||
return (attr["name"][2:], attr["flags"], attr["kind"],
|
||||
str_to_const_array(self.descriptor.interface.getClassName()))
|
||||
|
||||
flags = attr["flags"]
|
||||
if self.unforgeable:
|
||||
flags += " | JSPROP_PERMANENT"
|
||||
return (str_to_const_array(attr["attr"].identifier.name), flags, attr["is_accessor"], getter(attr),
|
||||
return (str_to_const_array(attr["attr"].identifier.name), flags, attr["kind"], getter(attr),
|
||||
setter(attr))
|
||||
|
||||
def template(m):
|
||||
|
@ -1977,7 +1977,7 @@ class AttrDefiner(PropertyDefiner):
|
|||
return """ JSPropertySpec {
|
||||
name: JSPropertySpec_Name { symbol_: SymbolCode::%s as usize + 1 },
|
||||
attributes_: (%s) as u8,
|
||||
isAccessor_: (%s),
|
||||
kind_: (%s),
|
||||
u: JSPropertySpec_AccessorsOrValue {
|
||||
value: JSPropertySpec_ValueWrapper {
|
||||
type_: JSPropertySpec_ValueWrapper_Type::String,
|
||||
|
@ -1991,7 +1991,7 @@ class AttrDefiner(PropertyDefiner):
|
|||
return """ JSPropertySpec {
|
||||
name: JSPropertySpec_Name { string_: %s as *const u8 as *const libc::c_char },
|
||||
attributes_: (%s) as u8,
|
||||
isAccessor_: (%s),
|
||||
kind_: (%s),
|
||||
u: JSPropertySpec_AccessorsOrValue {
|
||||
accessors: JSPropertySpec_AccessorsOrValue_Accessors {
|
||||
getter: JSPropertySpec_Accessor {
|
||||
|
@ -2361,7 +2361,6 @@ static CLASS_OPS: js::jsapi::JSClassOps = js::jsapi::JSClassOps {
|
|||
mayResolve: None,
|
||||
finalize: Some(%(finalizeHook)s),
|
||||
call: None,
|
||||
hasInstance: None,
|
||||
construct: None,
|
||||
trace: Some(%(traceHook)s),
|
||||
};
|
||||
|
@ -3620,7 +3619,6 @@ let traps = ProxyTraps {
|
|||
hasOwn: Some(hasOwn),
|
||||
getOwnEnumerablePropertyKeys: Some(%(getOwnEnumerablePropertyKeys)s),
|
||||
nativeCall: None,
|
||||
hasInstance: None,
|
||||
objectClassIs: None,
|
||||
className: Some(className),
|
||||
fun_toString: None,
|
||||
|
@ -5368,7 +5366,7 @@ class CGProxySpecialOperation(CGPerSignatureCall):
|
|||
}
|
||||
self.cgRoot.prepend(instantiateJSToNativeConversionTemplate(
|
||||
template, templateValues, declType, argument.identifier.name))
|
||||
self.cgRoot.prepend(CGGeneric("rooted!(in(*cx) let value = desc.value);"))
|
||||
self.cgRoot.prepend(CGGeneric("rooted!(in(*cx) let value = desc.value_);"))
|
||||
|
||||
def getArguments(self):
|
||||
args = [(a, process_arg(a.identifier.name, a)) for a in self.arguments]
|
||||
|
@ -5471,7 +5469,8 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
def __init__(self, descriptor):
|
||||
args = [Argument('*mut JSContext', 'cx'), Argument('RawHandleObject', 'proxy'),
|
||||
Argument('RawHandleId', 'id'),
|
||||
Argument('RawMutableHandle<PropertyDescriptor>', 'mut desc')]
|
||||
Argument('RawMutableHandle<PropertyDescriptor>', 'mut desc'),
|
||||
Argument('*mut bool', 'is_none')]
|
||||
CGAbstractExternMethod.__init__(self, descriptor, "getOwnPropertyDescriptor",
|
||||
"bool", args)
|
||||
self.descriptor = descriptor
|
||||
|
@ -5487,12 +5486,12 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
"""
|
||||
if !proxyhandler::is_platform_object_same_origin(cx, proxy) {
|
||||
if !proxyhandler::cross_origin_get_own_property_helper(
|
||||
cx, proxy, &CROSS_ORIGIN_PROPERTIES, id, desc
|
||||
cx, proxy, &CROSS_ORIGIN_PROPERTIES, id, desc, &mut *is_none
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if desc.obj.is_null() {
|
||||
return proxyhandler::cross_origin_property_fallback(cx, proxy, id, desc);
|
||||
if *is_none {
|
||||
return proxyhandler::cross_origin_property_fallback(cx, proxy, id, desc, &mut *is_none);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -5507,8 +5506,12 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
attrs = "JSPROP_ENUMERATE"
|
||||
if self.descriptor.operations['IndexedSetter'] is None:
|
||||
attrs += " | JSPROP_READONLY"
|
||||
fillDescriptor = ("desc.value = result_root.get();\n"
|
||||
"fill_property_descriptor(MutableHandle::from_raw(desc), proxy.get(), (%s) as u32);\n"
|
||||
fillDescriptor = ("set_property_descriptor(\n"
|
||||
" MutableHandle::from_raw(desc),\n"
|
||||
" result_root.handle(),\n"
|
||||
" (%s) as u32,\n"
|
||||
" &mut *is_none\n"
|
||||
");\n"
|
||||
"return true;" % attrs)
|
||||
templateValues = {
|
||||
'jsvalRef': 'result_root.handle_mut()',
|
||||
|
@ -5532,8 +5535,12 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
attrs = " | ".join(attrs)
|
||||
else:
|
||||
attrs = "0"
|
||||
fillDescriptor = ("desc.value = result_root.get();\n"
|
||||
"fill_property_descriptor(MutableHandle::from_raw(desc), proxy.get(), (%s) as u32);\n"
|
||||
fillDescriptor = ("set_property_descriptor(\n"
|
||||
" MutableHandle::from_raw(desc),\n"
|
||||
" result_root.handle(),\n"
|
||||
" (%s) as u32,\n"
|
||||
" &mut *is_none\n"
|
||||
");\n"
|
||||
"return true;" % attrs)
|
||||
templateValues = {
|
||||
'jsvalRef': 'result_root.handle_mut()',
|
||||
|
@ -5542,7 +5549,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
}
|
||||
|
||||
# See the similar-looking in CGDOMJSProxyHandler_get for the spec quote.
|
||||
condition = "RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id)"
|
||||
condition = "id.is_string() || id.is_int()"
|
||||
if indexedGetter:
|
||||
condition = "index.is_none() && (%s)" % condition
|
||||
# Once we start supporting OverrideBuiltins we need to make
|
||||
|
@ -5569,17 +5576,16 @@ get_expando_object(proxy, expando.handle_mut());
|
|||
let proxy_lt = Handle::from_raw(proxy);
|
||||
let id_lt = Handle::from_raw(id);
|
||||
if !expando.is_null() {
|
||||
if !JS_GetPropertyDescriptorById(*cx, expando.handle().into(), id, desc) {
|
||||
rooted!(in(*cx) let mut ignored = ptr::null_mut::<JSObject>());
|
||||
if !JS_GetPropertyDescriptorById(*cx, expando.handle().into(), id, desc, ignored.handle_mut().into(), is_none) {
|
||||
return false;
|
||||
}
|
||||
if !desc.obj.is_null() {
|
||||
if !*is_none {
|
||||
// Pretend the property lives on the wrapper.
|
||||
desc.obj = proxy.get();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
""" + namedGet + """\
|
||||
desc.obj = ptr::null_mut();
|
||||
return true;"""
|
||||
|
||||
def definition_body(self):
|
||||
|
@ -5628,12 +5634,12 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
|||
if self.descriptor.hasUnforgeableMembers:
|
||||
raise TypeError("Can't handle a named setter on an interface that has "
|
||||
"unforgeables. Figure out how that should work!")
|
||||
set += ("if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {\n"
|
||||
set += ("if id.is_string() || id.is_int() {\n"
|
||||
+ CGIndenter(CGProxyNamedSetter(self.descriptor)).define()
|
||||
+ " return (*opresult).succeed();\n"
|
||||
+ "}\n")
|
||||
elif self.descriptor.operations['NamedGetter']:
|
||||
set += ("if RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id) {\n"
|
||||
set += ("if id.is_string() || id.is_int() {\n"
|
||||
+ CGIndenter(CGProxyNamedGetter(self.descriptor)).define()
|
||||
+ " if result.is_some() {\n"
|
||||
" return (*opresult).failNoNamedSetter();\n"
|
||||
|
@ -5839,7 +5845,7 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
|||
+ "}\n\n")
|
||||
|
||||
namedGetter = self.descriptor.operations['NamedGetter']
|
||||
condition = "RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id)"
|
||||
condition = "id.is_string() || id.is_int()"
|
||||
if indexedGetter:
|
||||
condition = "index.is_none() && (%s)" % condition
|
||||
if namedGetter:
|
||||
|
@ -5939,7 +5945,7 @@ if !expando.is_null() {
|
|||
|
||||
namedGetter = self.descriptor.operations['NamedGetter']
|
||||
if namedGetter:
|
||||
condition = "RUST_JSID_IS_STRING(id) || RUST_JSID_IS_INT(id)"
|
||||
condition = "id.is_string() || id.is_int()"
|
||||
# From step 1:
|
||||
# If O supports indexed properties and P is an array index, then:
|
||||
#
|
||||
|
@ -6139,7 +6145,7 @@ class CGClassFinalizeHook(CGAbstractClassHook):
|
|||
A hook for finalize, used to release our native object.
|
||||
"""
|
||||
def __init__(self, descriptor):
|
||||
args = [Argument('*mut JSFreeOp', '_fop'), Argument('*mut JSObject', 'obj')]
|
||||
args = [Argument('*mut GCContext', '_cx'), Argument('*mut JSObject', 'obj')]
|
||||
CGAbstractClassHook.__init__(self, descriptor, FINALIZE_HOOK_NAME,
|
||||
'void', args)
|
||||
|
||||
|
@ -6302,6 +6308,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'js::jsapi::CallArgs',
|
||||
'js::jsapi::CurrentGlobalOrNull',
|
||||
'js::rust::wrappers::GetPropertyKeys',
|
||||
'js::jsapi::GCContext',
|
||||
'js::jsapi::GetWellKnownSymbol',
|
||||
'js::rust::Handle',
|
||||
'js::jsapi::Handle as RawHandle',
|
||||
|
@ -6320,7 +6327,6 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'js::jsapi::JSCLASS_RESERVED_SLOTS_SHIFT',
|
||||
'js::jsapi::JSClass',
|
||||
'js::jsapi::JSContext',
|
||||
'js::jsapi::JSFreeOp',
|
||||
'js::jsapi::JSFunctionSpec',
|
||||
'js::jsapi::JSITER_HIDDEN',
|
||||
'js::jsapi::JSITER_OWNONLY',
|
||||
|
@ -6345,6 +6351,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'js::jsapi::JSPropertySpec_Accessor',
|
||||
'js::jsapi::JSPropertySpec_AccessorsOrValue',
|
||||
'js::jsapi::JSPropertySpec_AccessorsOrValue_Accessors',
|
||||
'js::jsapi::JSPropertySpec_Kind',
|
||||
'js::jsapi::JSPropertySpec_Name',
|
||||
'js::jsapi::JSPropertySpec_ValueWrapper',
|
||||
'js::jsapi::JSPropertySpec_ValueWrapper_Type',
|
||||
|
@ -6414,8 +6421,6 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'js::glue::SetProxyReservedSlot',
|
||||
'js::rust::wrappers::NewProxyObject',
|
||||
'js::glue::ProxyTraps',
|
||||
'js::glue::RUST_JSID_IS_INT',
|
||||
'js::glue::RUST_JSID_IS_STRING',
|
||||
'js::rust::wrappers::RUST_SYMBOL_TO_JSID',
|
||||
'js::rust::wrappers::int_to_jsid',
|
||||
'js::glue::UnwrapObjectDynamic',
|
||||
|
@ -6521,7 +6526,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'crate::dom::bindings::inheritance::Castable',
|
||||
'crate::dom::bindings::proxyhandler',
|
||||
'crate::dom::bindings::proxyhandler::ensure_expando_object',
|
||||
'crate::dom::bindings::proxyhandler::fill_property_descriptor',
|
||||
'crate::dom::bindings::proxyhandler::set_property_descriptor',
|
||||
'crate::dom::bindings::proxyhandler::get_expando_object',
|
||||
'crate::dom::bindings::record::Record',
|
||||
'std::ptr::NonNull',
|
||||
|
|
|
@ -53,8 +53,6 @@ use js::error::throw_type_error;
|
|||
use js::glue::GetProxyReservedSlot;
|
||||
use js::glue::JS_GetReservedSlot;
|
||||
use js::glue::{IsWrapper, UnwrapObjectDynamic};
|
||||
use js::glue::{RUST_JSID_IS_INT, RUST_JSID_TO_INT};
|
||||
use js::glue::{RUST_JSID_IS_STRING, RUST_JSID_TO_STRING};
|
||||
use js::jsapi::{Heap, JSContext, JSObject, JSString};
|
||||
use js::jsapi::{IsWindowProxy, JS_DeprecatedStringHasLatin1Chars, JS_NewStringCopyN};
|
||||
use js::jsapi::{
|
||||
|
@ -160,13 +158,13 @@ where
|
|||
///
|
||||
/// Handling of invalid UTF-16 in strings depends on the relevant option.
|
||||
pub unsafe fn jsid_to_string(cx: *mut JSContext, id: HandleId) -> Option<DOMString> {
|
||||
let id_raw = id.into();
|
||||
if RUST_JSID_IS_STRING(id_raw) {
|
||||
return Some(jsstring_to_str(cx, RUST_JSID_TO_STRING(id_raw)));
|
||||
let id_raw = *id;
|
||||
if id_raw.is_string() {
|
||||
return Some(jsstring_to_str(cx, id_raw.to_string()));
|
||||
}
|
||||
|
||||
if RUST_JSID_IS_INT(id_raw) {
|
||||
return Some(RUST_JSID_TO_INT(id_raw).to_string().into());
|
||||
if id_raw.is_int() {
|
||||
return Some(id_raw.to_int().to_string().into());
|
||||
}
|
||||
|
||||
None
|
||||
|
|
|
@ -105,7 +105,6 @@ impl InterfaceConstructorBehavior {
|
|||
finalize: None,
|
||||
call: Some(invalid_constructor),
|
||||
construct: Some(invalid_constructor),
|
||||
hasInstance: None, // heycam/webidl#356
|
||||
trace: None,
|
||||
})
|
||||
}
|
||||
|
@ -122,7 +121,6 @@ impl InterfaceConstructorBehavior {
|
|||
finalize: None,
|
||||
call: Some(non_new_constructor),
|
||||
construct: Some(hook),
|
||||
hasInstance: None, // heycam/webidl#356
|
||||
trace: None,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -44,8 +44,8 @@ use js::jsval::ObjectValue;
|
|||
use js::jsval::UndefinedValue;
|
||||
use js::rust::wrappers::JS_AlreadyHasOwnPropertyById;
|
||||
use js::rust::wrappers::JS_NewObjectWithGivenProto;
|
||||
use js::rust::wrappers::{AppendToIdVector, RUST_INTERNED_STRING_TO_JSID};
|
||||
use js::rust::{get_context_realm, Handle, HandleObject, MutableHandle, MutableHandleObject};
|
||||
use js::rust::wrappers::{AppendToIdVector, RUST_INTERNED_STRING_TO_JSID, SetDataPropertyDescriptor};
|
||||
use js::rust::{get_context_realm, Handle, HandleObject, HandleValue, MutableHandle, MutableHandleObject};
|
||||
use std::{ffi::CStr, os::raw::c_char, ptr};
|
||||
|
||||
/// Determine if this id shadows any existing properties for this proxy.
|
||||
|
@ -189,15 +189,16 @@ pub unsafe fn ensure_expando_object(
|
|||
|
||||
/// Set the property descriptor's object to `obj` and set it to enumerable,
|
||||
/// and writable if `readonly` is true.
|
||||
pub fn fill_property_descriptor(
|
||||
mut desc: MutableHandle<PropertyDescriptor>,
|
||||
obj: *mut JSObject,
|
||||
pub fn set_property_descriptor(
|
||||
desc: MutableHandle<PropertyDescriptor>,
|
||||
value: HandleValue,
|
||||
attrs: u32,
|
||||
is_none: &mut bool,
|
||||
) {
|
||||
desc.obj = obj;
|
||||
desc.attrs = attrs;
|
||||
desc.getter = None;
|
||||
desc.setter = None;
|
||||
unsafe {
|
||||
SetDataPropertyDescriptor(desc, value, attrs);
|
||||
}
|
||||
*is_none = false;
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#isplatformobjectsameorigin-(-o-)>
|
||||
|
@ -333,12 +334,14 @@ pub unsafe extern "C" fn maybe_cross_origin_set_rawcx(
|
|||
// OrdinarySet
|
||||
// <https://tc39.es/ecma262/#sec-ordinaryset>
|
||||
rooted!(in(*cx) let mut own_desc = PropertyDescriptor::default());
|
||||
let mut is_none = false;
|
||||
if !InvokeGetOwnPropertyDescriptor(
|
||||
GetProxyHandler(*proxy),
|
||||
*cx,
|
||||
proxy,
|
||||
id,
|
||||
own_desc.handle_mut().into(),
|
||||
&mut is_none,
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
@ -439,26 +442,28 @@ pub unsafe fn cross_origin_get(
|
|||
) -> bool {
|
||||
// > 1. Let `desc` be `? O.[[GetOwnProperty]](P)`.
|
||||
rooted!(in(*cx) let mut descriptor = PropertyDescriptor::default());
|
||||
let mut is_none = false;
|
||||
if !InvokeGetOwnPropertyDescriptor(
|
||||
GetProxyHandler(*proxy),
|
||||
*cx,
|
||||
proxy,
|
||||
id,
|
||||
descriptor.handle_mut().into(),
|
||||
&mut is_none,
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// > 2. Assert: `desc` is not undefined.
|
||||
assert!(
|
||||
!descriptor.obj.is_null(),
|
||||
!is_none,
|
||||
"Callees should throw in all cases when they are not finding \
|
||||
a property decriptor"
|
||||
);
|
||||
|
||||
// > 3. If `! IsDataDescriptor(desc)` is true, then return `desc.[[Value]]`.
|
||||
if is_data_descriptor(&descriptor) {
|
||||
vp.set(descriptor.value);
|
||||
vp.set(descriptor.value_);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -504,19 +509,21 @@ pub unsafe fn cross_origin_set(
|
|||
) -> bool {
|
||||
// > 1. Let desc be ? O.[[GetOwnProperty]](P).
|
||||
rooted!(in(*cx) let mut descriptor = PropertyDescriptor::default());
|
||||
let mut is_none = false;
|
||||
if !InvokeGetOwnPropertyDescriptor(
|
||||
GetProxyHandler(*proxy),
|
||||
*cx,
|
||||
proxy,
|
||||
id,
|
||||
descriptor.handle_mut().into(),
|
||||
&mut is_none,
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// > 2. Assert: desc is not undefined.
|
||||
assert!(
|
||||
!descriptor.obj.is_null(),
|
||||
!is_none,
|
||||
"Callees should throw in all cases when they are not finding \
|
||||
a property decriptor"
|
||||
);
|
||||
|
@ -557,32 +564,25 @@ pub unsafe fn cross_origin_set(
|
|||
}
|
||||
|
||||
unsafe fn get_getter_object(d: &PropertyDescriptor, out: RawMutableHandleObject) {
|
||||
if (d.attrs & jsapi::JSPROP_GETTER as u32) != 0 {
|
||||
out.set(std::mem::transmute(d.getter));
|
||||
if d.hasGetter_() {
|
||||
out.set(std::mem::transmute(d.getter_));
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn get_setter_object(d: &PropertyDescriptor, out: RawMutableHandleObject) {
|
||||
if (d.attrs & jsapi::JSPROP_SETTER as u32) != 0 {
|
||||
out.set(std::mem::transmute(d.setter));
|
||||
if d.hasSetter_() {
|
||||
out.set(std::mem::transmute(d.setter_));
|
||||
}
|
||||
}
|
||||
|
||||
/// <https://tc39.es/ecma262/#sec-isaccessordescriptor>
|
||||
fn is_accessor_descriptor(d: &PropertyDescriptor) -> bool {
|
||||
d.attrs & (jsapi::JSPROP_GETTER as u32 | jsapi::JSPROP_SETTER as u32) != 0
|
||||
d.hasSetter_() || d.hasGetter_()
|
||||
}
|
||||
|
||||
/// <https://tc39.es/ecma262/#sec-isdatadescriptor>
|
||||
fn is_data_descriptor(d: &PropertyDescriptor) -> bool {
|
||||
let is_accessor = is_accessor_descriptor(d);
|
||||
let is_generic = d.attrs &
|
||||
(jsapi::JSPROP_GETTER as u32 |
|
||||
jsapi::JSPROP_SETTER as u32 |
|
||||
jsapi::JSPROP_IGNORE_READONLY |
|
||||
jsapi::JSPROP_IGNORE_VALUE) ==
|
||||
jsapi::JSPROP_IGNORE_READONLY | jsapi::JSPROP_IGNORE_VALUE;
|
||||
!is_accessor && !is_generic
|
||||
d.hasWritable_() || d.hasValue_()
|
||||
}
|
||||
|
||||
/// Evaluate `CrossOriginGetOwnPropertyHelper(proxy, id) != null`.
|
||||
|
@ -621,7 +621,8 @@ pub unsafe fn cross_origin_get_own_property_helper(
|
|||
proxy: RawHandleObject,
|
||||
cross_origin_properties: &'static CrossOriginProperties,
|
||||
id: RawHandleId,
|
||||
mut desc: RawMutableHandle<PropertyDescriptor>,
|
||||
desc: RawMutableHandle<PropertyDescriptor>,
|
||||
is_none: &mut bool,
|
||||
) -> bool {
|
||||
rooted!(in(*cx) let mut holder = ptr::null_mut::<JSObject>());
|
||||
|
||||
|
@ -632,15 +633,7 @@ pub unsafe fn cross_origin_get_own_property_helper(
|
|||
holder.handle_mut().into(),
|
||||
);
|
||||
|
||||
if !JS_GetOwnPropertyDescriptorById(*cx, holder.handle().into(), id, desc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if !desc.obj.is_null() {
|
||||
desc.obj = proxy.get();
|
||||
}
|
||||
|
||||
true
|
||||
return JS_GetOwnPropertyDescriptorById(*cx, holder.handle().into(), id, desc, is_none);
|
||||
}
|
||||
|
||||
/// Implementation of [`CrossOriginPropertyFallback`].
|
||||
|
@ -651,24 +644,24 @@ pub unsafe fn cross_origin_get_own_property_helper(
|
|||
/// [`CrossOriginPropertyFallback`]: https://html.spec.whatwg.org/multipage/#crossoriginpropertyfallback-(-p-)
|
||||
pub unsafe fn cross_origin_property_fallback(
|
||||
cx: SafeJSContext,
|
||||
proxy: RawHandleObject,
|
||||
_proxy: RawHandleObject,
|
||||
id: RawHandleId,
|
||||
mut desc: RawMutableHandle<PropertyDescriptor>,
|
||||
desc: RawMutableHandle<PropertyDescriptor>,
|
||||
is_none: &mut bool,
|
||||
) -> bool {
|
||||
assert!(desc.obj.is_null(), "why are we being called?");
|
||||
assert!(*is_none, "why are we being called?");
|
||||
|
||||
// > 1. If P is `then`, `@@toStringTag`, `@@hasInstance`, or
|
||||
// > `@@isConcatSpreadable`, then return `PropertyDescriptor{ [[Value]]:
|
||||
// > undefined, [[Writable]]: false, [[Enumerable]]: false,
|
||||
// > [[Configurable]]: true }`.
|
||||
if is_cross_origin_allowlisted_prop(cx, id) {
|
||||
*desc = PropertyDescriptor {
|
||||
getter: None,
|
||||
setter: None,
|
||||
value: UndefinedValue(),
|
||||
attrs: jsapi::JSPROP_READONLY as u32,
|
||||
obj: proxy.get(),
|
||||
};
|
||||
set_property_descriptor(
|
||||
MutableHandle::from_raw(desc),
|
||||
HandleValue::undefined(),
|
||||
jsapi::JSPROP_READONLY as u32,
|
||||
is_none,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -695,7 +688,7 @@ unsafe fn is_cross_origin_allowlisted_prop(cx: SafeJSContext, id: RawHandleId) -
|
|||
);
|
||||
// `jsid`s containing `JS::Symbol *` can be compared by
|
||||
// referential equality
|
||||
allowed_id.get().asBits == id.asBits
|
||||
allowed_id.get().asBits_ == id.asBits_
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ use js::jsval::ObjectValue;
|
|||
use js::jsval::UndefinedValue;
|
||||
use js::rust::wrappers::GetPropertyKeys;
|
||||
use js::rust::wrappers::JS_DefineUCProperty2;
|
||||
use js::rust::wrappers::JS_GetOwnPropertyDescriptorById;
|
||||
use js::jsapi::glue::JS_GetOwnPropertyDescriptorById;
|
||||
use js::rust::wrappers::JS_GetPropertyById;
|
||||
use js::rust::wrappers::JS_IdToValue;
|
||||
use js::rust::HandleId;
|
||||
|
@ -135,12 +135,13 @@ where
|
|||
rooted!(in(cx) let id = *id);
|
||||
rooted!(in(cx) let mut desc = PropertyDescriptor::default());
|
||||
|
||||
if !JS_GetOwnPropertyDescriptorById(cx, object.handle(), id.handle(), desc.handle_mut())
|
||||
let mut is_none = false;
|
||||
if !JS_GetOwnPropertyDescriptorById(cx, object.handle().into(), id.handle().into(), desc.handle_mut().into(), &mut is_none)
|
||||
{
|
||||
return Err(());
|
||||
}
|
||||
|
||||
if (JSPROP_ENUMERATE as u32) & desc.attrs == 0 {
|
||||
if !desc.enumerable_() {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -306,6 +306,7 @@ pub fn write(
|
|||
let policy = CloneDataPolicy {
|
||||
allowIntraClusterClonableSharedObjects_: false,
|
||||
allowSharedMemoryObjects_: false,
|
||||
allowErrorStackFrames_: false,
|
||||
};
|
||||
let result = JS_WriteStructuredClone(
|
||||
*cx,
|
||||
|
@ -382,6 +383,7 @@ pub fn read(
|
|||
&CloneDataPolicy {
|
||||
allowIntraClusterClonableSharedObjects_: false,
|
||||
allowSharedMemoryObjects_: false,
|
||||
allowErrorStackFrames_: false,
|
||||
},
|
||||
&STRUCTURED_CLONE_CALLBACKS,
|
||||
sc_holder_ptr as *mut raw::c_void,
|
||||
|
|
|
@ -82,7 +82,7 @@ use js::jsapi::{
|
|||
GCTraceKindToAscii, Heap, JSObject, JSScript, JSString, JSTracer, JobQueue, TraceKind,
|
||||
};
|
||||
use js::jsval::JSVal;
|
||||
use js::rust::{GCMethods, Handle, Runtime};
|
||||
use js::rust::{GCMethods, Handle, Runtime, Stencil};
|
||||
use js::typedarray::TypedArray;
|
||||
use js::typedarray::TypedArrayElement;
|
||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||
|
@ -677,6 +677,7 @@ unsafe_no_jsmanaged_fields!(MediaMetadata);
|
|||
unsafe_no_jsmanaged_fields!(WebrenderIpcSender);
|
||||
unsafe_no_jsmanaged_fields!(StreamConsumer);
|
||||
unsafe_no_jsmanaged_fields!(DocumentAnimationSet);
|
||||
unsafe_no_jsmanaged_fields!(Stencil);
|
||||
|
||||
unsafe impl<'a> JSTraceable for &'a str {
|
||||
#[inline]
|
||||
|
|
|
@ -19,10 +19,8 @@ use crate::script_runtime::JSContext as SafeJSContext;
|
|||
use js::conversions::ToJSValConvertible;
|
||||
use js::glue::JS_GetReservedSlot;
|
||||
use js::glue::{CallJitGetterOp, CallJitMethodOp, CallJitSetterOp, IsWrapper};
|
||||
use js::glue::{UnwrapObjectDynamic, UnwrapObjectStatic, RUST_JSID_TO_INT, RUST_JSID_TO_STRING};
|
||||
use js::glue::{
|
||||
RUST_FUNCTION_VALUE_TO_JITINFO, RUST_JSID_IS_INT, RUST_JSID_IS_STRING, RUST_JSID_IS_VOID,
|
||||
};
|
||||
use js::glue::{UnwrapObjectDynamic, UnwrapObjectStatic};
|
||||
use js::glue::RUST_FUNCTION_VALUE_TO_JITINFO;
|
||||
use js::jsapi::HandleId as RawHandleId;
|
||||
use js::jsapi::HandleObject as RawHandleObject;
|
||||
use js::jsapi::MutableHandleIdVector as RawMutableHandleIdVector;
|
||||
|
@ -192,16 +190,16 @@ pub unsafe fn get_property_on_prototype(
|
|||
/// Get an array index from the given `jsid`. Returns `None` if the given
|
||||
/// `jsid` is not an integer.
|
||||
pub unsafe fn get_array_index_from_id(_cx: *mut JSContext, id: HandleId) -> Option<u32> {
|
||||
let raw_id = id.into();
|
||||
if RUST_JSID_IS_INT(raw_id) {
|
||||
return Some(RUST_JSID_TO_INT(raw_id) as u32);
|
||||
let raw_id = *id;
|
||||
if raw_id.is_int() {
|
||||
return Some(raw_id.to_int() as u32);
|
||||
}
|
||||
|
||||
if RUST_JSID_IS_VOID(raw_id) || !RUST_JSID_IS_STRING(raw_id) {
|
||||
if raw_id.is_void() || !raw_id.is_string() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let atom = RUST_JSID_TO_STRING(raw_id) as *mut JSAtom;
|
||||
let atom = raw_id.to_string() as *mut JSAtom;
|
||||
let s = AtomToLinearString(atom);
|
||||
if GetLinearStringLength(s) == 0 {
|
||||
return None;
|
||||
|
@ -451,12 +449,12 @@ pub unsafe extern "C" fn resolve_global(
|
|||
if *rval {
|
||||
return true;
|
||||
}
|
||||
if !RUST_JSID_IS_STRING(id) {
|
||||
if !id.is_string() {
|
||||
*rval = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
let string = RUST_JSID_TO_STRING(id);
|
||||
let string = id.to_string();
|
||||
if !JS_DeprecatedStringHasLatin1Chars(string) {
|
||||
*rval = false;
|
||||
return true;
|
||||
|
|
|
@ -82,7 +82,7 @@ use js::glue::{IsWrapper, UnwrapObjectDynamic};
|
|||
use js::jsapi::Compile1;
|
||||
use js::jsapi::SetScriptPrivate;
|
||||
use js::jsapi::{CurrentGlobalOrNull, GetNonCCWObjectGlobal};
|
||||
use js::jsapi::{HandleObject, Heap};
|
||||
use js::jsapi::{HandleObject, Heap, InstantiateOptions, InstantiateGlobalStencil};
|
||||
use js::jsapi::{JSContext, JSObject, JSScript};
|
||||
use js::jsval::PrivateValue;
|
||||
use js::jsval::{JSVal, UndefinedValue};
|
||||
|
@ -120,6 +120,7 @@ use std::collections::hash_map::Entry;
|
|||
use std::collections::{HashMap, VecDeque};
|
||||
use std::mem;
|
||||
use std::ops::Index;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
|
@ -2625,7 +2626,13 @@ impl GlobalScope {
|
|||
}
|
||||
},
|
||||
SourceCode::Compiled(pre_compiled_script) => {
|
||||
compiled_script.set(pre_compiled_script.source_code.get());
|
||||
let options = InstantiateOptions {
|
||||
skipFilenameValidation: false,
|
||||
hideScriptFromDebugger: false,
|
||||
deferDebugMetadata: false,
|
||||
};
|
||||
let script = InstantiateGlobalStencil(*cx, &options, *pre_compiled_script.source_code, ptr::null_mut());
|
||||
compiled_script.set(script);
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ use crate::dom::bindings::reflector::DomObject;
|
|||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::bindings::settings_stack::AutoEntryScript;
|
||||
use crate::dom::bindings::str::{DOMString, USVString};
|
||||
use crate::dom::bindings::trace::RootedTraceableBox;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::{
|
||||
cors_setting_for_element, referrer_policy_for_element, reflect_cross_origin_attribute,
|
||||
|
@ -44,10 +43,10 @@ use html5ever::{LocalName, Prefix};
|
|||
use ipc_channel::ipc;
|
||||
use ipc_channel::router::ROUTER;
|
||||
use js::jsapi::{
|
||||
CanCompileOffThread, CompileOffThread1, FinishOffThreadScript, Heap, JSScript, OffThreadToken,
|
||||
CanCompileOffThread, CompileToStencilOffThread1, OffThreadToken,
|
||||
};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::{transform_str_to_source_text, CompileOptionsWrapper};
|
||||
use js::rust::{transform_str_to_source_text, CompileOptionsWrapper, FinishOffThreadStencil, Stencil};
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use net_traits::request::{
|
||||
CorsSettings, CredentialsMode, Destination, ParserMetadata, RequestBuilder,
|
||||
|
@ -66,6 +65,7 @@ use std::io::{Read, Seek, Write};
|
|||
use std::mem::replace;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use style::str::{StaticStringVec, HTML_SPACE_CHARACTERS};
|
||||
|
@ -113,21 +113,16 @@ unsafe extern "C" fn off_thread_compilation_callback(
|
|||
let cx = global.get_cx();
|
||||
let _ar = enter_realm(&*global);
|
||||
|
||||
rooted!(in(*cx)
|
||||
let compiled_script = FinishOffThreadScript(*cx, token.0)
|
||||
);
|
||||
let compiled_script = FinishOffThreadStencil(*cx, token.0, ptr::null_mut());
|
||||
|
||||
let load = if compiled_script.get().is_null() {
|
||||
let load = if compiled_script.is_null() {
|
||||
Err(NetworkError::Internal(
|
||||
"Off-thread compilation failed.".into(),
|
||||
))
|
||||
} else {
|
||||
let script_text = DOMString::from(script);
|
||||
let heap = Heap::default();
|
||||
let source_code = RootedTraceableBox::new(heap);
|
||||
source_code.set(compiled_script.get());
|
||||
let code = SourceCode::Compiled(CompiledSourceCode {
|
||||
source_code: source_code,
|
||||
source_code: compiled_script,
|
||||
original_text: Rc::new(script_text),
|
||||
});
|
||||
|
||||
|
@ -244,7 +239,7 @@ pub enum ScriptType {
|
|||
#[derive(JSTraceable, MallocSizeOf)]
|
||||
pub struct CompiledSourceCode {
|
||||
#[ignore_malloc_size_of = "SM handles JS values"]
|
||||
pub source_code: RootedTraceableBox<Heap<*mut JSScript>>,
|
||||
pub source_code: Stencil,
|
||||
#[ignore_malloc_size_of = "Rc is hard"]
|
||||
pub original_text: Rc<DOMString>,
|
||||
}
|
||||
|
@ -446,7 +441,7 @@ impl FetchResponseListener for ClassicContext {
|
|||
});
|
||||
|
||||
unsafe {
|
||||
assert!(!CompileOffThread1(
|
||||
assert!(!CompileToStencilOffThread1(
|
||||
*cx,
|
||||
options.ptr as *const _,
|
||||
&mut transform_str_to_source_text(&context.script_text) as *mut _,
|
||||
|
@ -1113,7 +1108,8 @@ impl HTMLScriptElement {
|
|||
.map(|record| record.handle());
|
||||
|
||||
if let Some(record) = record {
|
||||
let evaluated = module_tree.execute_module(global, record);
|
||||
rooted!(in(*global.get_cx()) let mut rval = UndefinedValue());
|
||||
let evaluated = module_tree.execute_module(global, record, rval.handle_mut().into());
|
||||
|
||||
if let Err(exception) = evaluated {
|
||||
module_tree.set_rethrow_error(exception);
|
||||
|
|
|
@ -24,7 +24,8 @@ use js::jsapi::{
|
|||
ReadableStreamDefaultReaderRead, ReadableStreamError, ReadableStreamGetReader,
|
||||
ReadableStreamIsDisturbed, ReadableStreamIsLocked, ReadableStreamIsReadable,
|
||||
ReadableStreamReaderMode, ReadableStreamReaderReleaseLock, ReadableStreamUnderlyingSource,
|
||||
ReadableStreamUpdateDataAvailableFromSource, UnwrapReadableStream,
|
||||
ReadableStreamUpdateDataAvailableFromSource, UnwrapReadableStream, JS_GetArrayBufferViewData,
|
||||
AutoRequireNoGC,
|
||||
};
|
||||
use js::jsval::JSVal;
|
||||
use js::jsval::UndefinedValue;
|
||||
|
@ -332,11 +333,14 @@ unsafe extern "C" fn write_into_read_request_buffer(
|
|||
source: *const c_void,
|
||||
_cx: *mut JSContext,
|
||||
_stream: HandleObject,
|
||||
buffer: *mut c_void,
|
||||
chunk: HandleObject,
|
||||
length: usize,
|
||||
bytes_written: *mut usize,
|
||||
) {
|
||||
let source = &*(source as *const ExternalUnderlyingSourceController);
|
||||
let mut is_shared_memory = false;
|
||||
let buffer = JS_GetArrayBufferViewData(*chunk, &mut is_shared_memory, &AutoRequireNoGC { _address: 0 });
|
||||
assert!(!is_shared_memory);
|
||||
let slice = slice::from_raw_parts_mut(buffer as *mut u8, length);
|
||||
source.write_into_buffer(slice);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::dom::bindings::cell::DomRefCell;
|
|||
use crate::dom::bindings::conversions::{root_from_handleobject, ToJSValConvertible};
|
||||
use crate::dom::bindings::error::{throw_dom_exception, Error, Fallible};
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::proxyhandler::fill_property_descriptor;
|
||||
use crate::dom::bindings::proxyhandler::set_property_descriptor;
|
||||
use crate::dom::bindings::reflector::{DomObject, Reflector};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::bindings::str::{DOMString, USVString};
|
||||
|
@ -25,7 +25,9 @@ use embedder_traits::EmbedderMsg;
|
|||
use indexmap::map::IndexMap;
|
||||
use ipc_channel::ipc;
|
||||
use js::glue::{CreateWrapperProxyHandler, ProxyTraps};
|
||||
use js::glue::{GetProxyPrivate, GetProxyReservedSlot, SetProxyReservedSlot};
|
||||
use js::glue::{
|
||||
GetProxyPrivate, GetProxyReservedSlot, SetProxyReservedSlot,
|
||||
};
|
||||
use js::jsapi::Handle as RawHandle;
|
||||
use js::jsapi::HandleId as RawHandleId;
|
||||
use js::jsapi::HandleObject as RawHandleObject;
|
||||
|
@ -33,7 +35,7 @@ use js::jsapi::HandleValue as RawHandleValue;
|
|||
use js::jsapi::MutableHandle as RawMutableHandle;
|
||||
use js::jsapi::MutableHandleObject as RawMutableHandleObject;
|
||||
use js::jsapi::MutableHandleValue as RawMutableHandleValue;
|
||||
use js::jsapi::{JSAutoRealm, JSContext, JSErrNum, JSFreeOp, JSObject};
|
||||
use js::jsapi::{JSAutoRealm, JSContext, JSErrNum, JSObject, GCContext};
|
||||
use js::jsapi::{JSTracer, JS_DefinePropertyById, JSPROP_ENUMERATE, JSPROP_READONLY};
|
||||
use js::jsapi::{JS_ForwardGetPropertyTo, JS_ForwardSetPropertyTo};
|
||||
use js::jsapi::{JS_GetOwnPropertyDescriptorById, JS_IsExceptionPending};
|
||||
|
@ -901,30 +903,26 @@ unsafe extern "C" fn getOwnPropertyDescriptor(
|
|||
cx: *mut JSContext,
|
||||
proxy: RawHandleObject,
|
||||
id: RawHandleId,
|
||||
mut desc: RawMutableHandle<PropertyDescriptor>,
|
||||
desc: RawMutableHandle<PropertyDescriptor>,
|
||||
is_none: *mut bool,
|
||||
) -> bool {
|
||||
let window = GetSubframeWindowProxy(cx, proxy, id);
|
||||
if let Some((window, attrs)) = window {
|
||||
rooted!(in(cx) let mut val = UndefinedValue());
|
||||
window.to_jsval(cx, val.handle_mut());
|
||||
desc.value = val.get();
|
||||
fill_property_descriptor(MutableHandle::from_raw(desc), proxy.get(), attrs);
|
||||
set_property_descriptor(
|
||||
MutableHandle::from_raw(desc),
|
||||
val.handle().into(),
|
||||
attrs,
|
||||
&mut *is_none,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
let mut slot = UndefinedValue();
|
||||
GetProxyPrivate(proxy.get(), &mut slot);
|
||||
rooted!(in(cx) let target = slot.to_object());
|
||||
if !JS_GetOwnPropertyDescriptorById(cx, target.handle().into(), id, desc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
assert!(desc.obj.is_null() || desc.obj == target.get());
|
||||
if desc.obj == target.get() {
|
||||
desc.obj = proxy.get();
|
||||
}
|
||||
|
||||
true
|
||||
return JS_GetOwnPropertyDescriptorById(cx, target.handle().into(), id, desc, is_none);
|
||||
}
|
||||
|
||||
#[allow(unsafe_code, non_snake_case)]
|
||||
|
@ -1062,7 +1060,6 @@ static PROXY_HANDLER: ProxyTraps = ProxyTraps {
|
|||
hasOwn: None,
|
||||
getOwnEnumerablePropertyKeys: None,
|
||||
nativeCall: None,
|
||||
hasInstance: None,
|
||||
objectClassIs: None,
|
||||
className: None,
|
||||
fun_toString: None,
|
||||
|
@ -1161,10 +1158,11 @@ unsafe extern "C" fn getOwnPropertyDescriptor_xorigin(
|
|||
proxy: RawHandleObject,
|
||||
id: RawHandleId,
|
||||
desc: RawMutableHandle<PropertyDescriptor>,
|
||||
is_none: *mut bool,
|
||||
) -> bool {
|
||||
let mut found = false;
|
||||
has_xorigin(cx, proxy, id, &mut found);
|
||||
found && getOwnPropertyDescriptor(cx, proxy, id, desc)
|
||||
found && getOwnPropertyDescriptor(cx, proxy, id, desc, is_none)
|
||||
}
|
||||
|
||||
#[allow(unsafe_code, non_snake_case)]
|
||||
|
@ -1210,7 +1208,6 @@ static XORIGIN_PROXY_HANDLER: ProxyTraps = ProxyTraps {
|
|||
hasOwn: Some(has_xorigin),
|
||||
getOwnEnumerablePropertyKeys: None,
|
||||
nativeCall: None,
|
||||
hasInstance: None,
|
||||
objectClassIs: None,
|
||||
className: None,
|
||||
fun_toString: None,
|
||||
|
@ -1226,7 +1223,7 @@ static XORIGIN_PROXY_HANDLER: ProxyTraps = ProxyTraps {
|
|||
// How WindowProxy objects are garbage collected.
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn finalize(_fop: *mut JSFreeOp, obj: *mut JSObject) {
|
||||
unsafe extern "C" fn finalize(_fop: *mut GCContext, obj: *mut JSObject) {
|
||||
let mut slot = UndefinedValue();
|
||||
GetProxyReservedSlot(obj, 0, &mut slot);
|
||||
let this = slot.to_private() as *mut WindowProxy;
|
||||
|
|
|
@ -44,15 +44,16 @@ use ipc_channel::router::ROUTER;
|
|||
use js::jsapi::Handle as RawHandle;
|
||||
use js::jsapi::HandleObject;
|
||||
use js::jsapi::HandleValue as RawHandleValue;
|
||||
use js::jsapi::MutableHandleValue;
|
||||
use js::jsapi::Value;
|
||||
use js::jsapi::{CompileModule1, ExceptionStackBehavior, FinishDynamicModuleImport_NoTLA};
|
||||
use js::jsapi::{DynamicImportStatus, SetModuleDynamicImportHook, SetScriptPrivateReferenceHooks};
|
||||
use js::jsapi::{CompileModule1, ExceptionStackBehavior, FinishDynamicModuleImport};
|
||||
use js::jsapi::{SetModuleDynamicImportHook, SetScriptPrivateReferenceHooks};
|
||||
use js::jsapi::{GetModuleResolveHook, JSRuntime, SetModuleResolveHook};
|
||||
use js::jsapi::{GetRequestedModules, SetModuleMetadataHook};
|
||||
use js::jsapi::{GetRequestedModules, SetModuleMetadataHook, GetModuleRequestSpecifier};
|
||||
use js::jsapi::{Heap, JSContext, JS_ClearPendingException, SetModulePrivate};
|
||||
use js::jsapi::{JSAutoRealm, JSObject, JSString};
|
||||
use js::jsapi::{JS_DefineProperty4, JS_IsExceptionPending, JS_NewStringCopyN, JSPROP_ENUMERATE};
|
||||
use js::jsapi::{ModuleEvaluate, ModuleInstantiate};
|
||||
use js::jsapi::{ModuleEvaluate, ModuleLink};
|
||||
use js::jsval::{JSVal, PrivateValue, UndefinedValue};
|
||||
use js::rust::jsapi_wrapped::{GetArrayLength, JS_GetElement};
|
||||
use js::rust::jsapi_wrapped::{GetRequestedModuleSpecifier, JS_GetPendingException};
|
||||
|
@ -71,6 +72,7 @@ use net_traits::{ResourceFetchTiming, ResourceTimingType};
|
|||
use servo_url::ServoUrl;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
use std::str::FromStr;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
@ -475,8 +477,8 @@ impl ModuleTree {
|
|||
let _ac = JSAutoRealm::new(*global.get_cx(), *global.reflector().get_jsobject());
|
||||
|
||||
unsafe {
|
||||
if !ModuleInstantiate(*global.get_cx(), module_record) {
|
||||
warn!("fail to instantiate module");
|
||||
if !ModuleLink(*global.get_cx(), module_record) {
|
||||
warn!("fail to link & instantiate module");
|
||||
|
||||
rooted!(in(*global.get_cx()) let mut exception = UndefinedValue());
|
||||
assert!(JS_GetPendingException(
|
||||
|
@ -501,12 +503,12 @@ impl ModuleTree {
|
|||
&self,
|
||||
global: &GlobalScope,
|
||||
module_record: HandleObject,
|
||||
eval_result: MutableHandleValue,
|
||||
) -> Result<(), RethrowError> {
|
||||
let _ac = JSAutoRealm::new(*global.get_cx(), *global.reflector().get_jsobject());
|
||||
|
||||
unsafe {
|
||||
rooted!(in(*global.get_cx()) let mut rval = UndefinedValue());
|
||||
if !ModuleEvaluate(*global.get_cx(), module_record, rval.handle_mut().into()) {
|
||||
if !ModuleEvaluate(*global.get_cx(), module_record, eval_result) {
|
||||
warn!("fail to evaluate module");
|
||||
|
||||
rooted!(in(*global.get_cx()) let mut exception = UndefinedValue());
|
||||
|
@ -973,6 +975,7 @@ impl ModuleOwner {
|
|||
let network_error = module_tree.get_network_error().borrow().as_ref().cloned();
|
||||
let existing_rethrow_error = module_tree.get_rethrow_error().borrow().as_ref().cloned();
|
||||
|
||||
rooted!(in(*global.get_cx()) let mut rval = UndefinedValue());
|
||||
let execution_err = if network_error.is_none() && existing_rethrow_error.is_none() {
|
||||
let record = module_tree
|
||||
.get_record()
|
||||
|
@ -981,7 +984,7 @@ impl ModuleOwner {
|
|||
.map(|record| record.handle());
|
||||
|
||||
if let Some(record) = record {
|
||||
let evaluated = module_tree.execute_module(&global, record).err();
|
||||
let evaluated = module_tree.execute_module(&global, record, rval.handle_mut().into()).err();
|
||||
|
||||
if let Some(exception) = evaluated.clone() {
|
||||
module_tree.set_rethrow_error(exception);
|
||||
|
@ -996,11 +999,10 @@ impl ModuleOwner {
|
|||
};
|
||||
|
||||
// Ensure any failures related to importing this dynamic module are immediately reported.
|
||||
let status = match (network_error, existing_rethrow_error, execution_err) {
|
||||
match (network_error, existing_rethrow_error, execution_err) {
|
||||
(Some(_), _, _) => unsafe {
|
||||
let err = gen_type_error(&global, "Dynamic import failed".to_owned());
|
||||
JS_SetPendingException(*cx, err.handle(), ExceptionStackBehavior::Capture);
|
||||
DynamicImportStatus::Failed
|
||||
},
|
||||
(None, _, Some(execution_err)) => unsafe {
|
||||
JS_SetPendingException(
|
||||
|
@ -1008,7 +1010,6 @@ impl ModuleOwner {
|
|||
execution_err.handle(),
|
||||
ExceptionStackBehavior::Capture,
|
||||
);
|
||||
DynamicImportStatus::Failed
|
||||
},
|
||||
(None, Some(rethrow_error), _) => unsafe {
|
||||
JS_SetPendingException(
|
||||
|
@ -1016,18 +1017,22 @@ impl ModuleOwner {
|
|||
rethrow_error.handle(),
|
||||
ExceptionStackBehavior::Capture,
|
||||
);
|
||||
DynamicImportStatus::Failed
|
||||
},
|
||||
// do nothing if there's no errors
|
||||
(None, None, None) => DynamicImportStatus::Ok,
|
||||
(None, None, None) => {}
|
||||
};
|
||||
|
||||
debug!("Finishing dynamic import for {:?}", module_identity);
|
||||
|
||||
rooted!(in(*cx) let mut evaluation_promise = ptr::null_mut::<JSObject>());
|
||||
if rval.is_object() {
|
||||
evaluation_promise.set(rval.to_object());
|
||||
}
|
||||
|
||||
unsafe {
|
||||
FinishDynamicModuleImport_NoTLA(
|
||||
FinishDynamicModuleImport(
|
||||
*cx,
|
||||
status,
|
||||
evaluation_promise.handle().into(),
|
||||
module.referencing_private.handle(),
|
||||
module.specifier.handle(),
|
||||
module.promise.reflector().get_jsobject().into_handle(),
|
||||
|
@ -1249,7 +1254,7 @@ unsafe extern "C" fn host_release_top_level_script(value: *const Value) {
|
|||
pub unsafe extern "C" fn host_import_module_dynamically(
|
||||
cx: *mut JSContext,
|
||||
reference_private: RawHandleValue,
|
||||
specifier: RawHandle<*mut JSString>,
|
||||
specifier: RawHandle<*mut JSObject>,
|
||||
promise: RawHandle<*mut JSObject>,
|
||||
) -> bool {
|
||||
// Step 1.
|
||||
|
@ -1339,14 +1344,16 @@ unsafe fn module_script_from_reference_private<'a>(
|
|||
#[allow(unsafe_code)]
|
||||
fn fetch_an_import_module_script_graph(
|
||||
global: &GlobalScope,
|
||||
specifier: RawHandle<*mut JSString>,
|
||||
module_request: RawHandle<*mut JSObject>,
|
||||
reference_private: RawHandleValue,
|
||||
base_url: ServoUrl,
|
||||
options: ScriptFetchOptions,
|
||||
promise: Rc<Promise>,
|
||||
) -> Result<(), RethrowError> {
|
||||
// Step 1.
|
||||
let url = ModuleTree::resolve_module_specifier(*global.get_cx(), &base_url, specifier);
|
||||
let cx = global.get_cx();
|
||||
rooted!(in(*cx) let specifier = unsafe { GetModuleRequestSpecifier(*cx, module_request) });
|
||||
let url = ModuleTree::resolve_module_specifier(*cx, &base_url, specifier.handle().into());
|
||||
|
||||
// Step 2.
|
||||
if url.is_err() {
|
||||
|
@ -1373,7 +1380,7 @@ fn fetch_an_import_module_script_graph(
|
|||
referencing_private: Heap::default(),
|
||||
id: dynamic_module_id,
|
||||
});
|
||||
dynamic_module.specifier.set(specifier.get());
|
||||
dynamic_module.specifier.set(module_request.get());
|
||||
dynamic_module
|
||||
.referencing_private
|
||||
.set(reference_private.get());
|
||||
|
@ -1402,7 +1409,7 @@ fn fetch_an_import_module_script_graph(
|
|||
unsafe extern "C" fn HostResolveImportedModule(
|
||||
cx: *mut JSContext,
|
||||
reference_private: RawHandleValue,
|
||||
specifier: RawHandle<*mut JSString>,
|
||||
specifier: RawHandle<*mut JSObject>,
|
||||
) -> *mut JSObject {
|
||||
let in_realm_proof = AlreadyInRealm::assert_for_cx(SafeJSContext::from_ptr(cx));
|
||||
let global_scope = GlobalScope::from_context(cx, InRealm::Already(&in_realm_proof));
|
||||
|
@ -1417,7 +1424,8 @@ unsafe extern "C" fn HostResolveImportedModule(
|
|||
}
|
||||
|
||||
// Step 5.
|
||||
let url = ModuleTree::resolve_module_specifier(*global_scope.get_cx(), &base_url, specifier);
|
||||
rooted!(in(*global_scope.get_cx()) let specifier = GetModuleRequestSpecifier(cx, specifier));
|
||||
let url = ModuleTree::resolve_module_specifier(*global_scope.get_cx(), &base_url, specifier.handle().into());
|
||||
|
||||
// Step 6.
|
||||
assert!(url.is_ok());
|
||||
|
@ -1542,7 +1550,7 @@ struct DynamicModule {
|
|||
#[ignore_malloc_size_of = "Rc is hard"]
|
||||
promise: Rc<Promise>,
|
||||
#[ignore_malloc_size_of = "GC types are hard"]
|
||||
specifier: Heap<*mut JSString>,
|
||||
specifier: Heap<*mut JSObject>,
|
||||
#[ignore_malloc_size_of = "GC types are hard"]
|
||||
referencing_private: Heap<JSVal>,
|
||||
#[ignore_malloc_size_of = "Defined in uuid"]
|
||||
|
|
|
@ -52,7 +52,7 @@ use js::jsapi::StreamConsumer as JSStreamConsumer;
|
|||
use js::jsapi::{BuildIdCharVector, DisableIncrementalGC, GCDescription, GCProgress};
|
||||
use js::jsapi::{Dispatchable as JSRunnable, Dispatchable_MaybeShuttingDown};
|
||||
use js::jsapi::{
|
||||
GCReason, JSGCInvocationKind, JSGCStatus, JS_AddExtraGCRootsTracer,
|
||||
GCReason, GCOptions, JSGCStatus, JS_AddExtraGCRootsTracer,
|
||||
JS_RequestInterruptCallback, JS_SetGCCallback,
|
||||
};
|
||||
use js::jsapi::{HandleObject, Heap, JobQueue};
|
||||
|
@ -791,13 +791,14 @@ unsafe extern "C" fn gc_slice_callback(
|
|||
};
|
||||
if !desc.is_null() {
|
||||
let desc: &GCDescription = &*desc;
|
||||
let invocation_kind = match desc.invocationKind_ {
|
||||
JSGCInvocationKind::GC_NORMAL => "GC_NORMAL",
|
||||
JSGCInvocationKind::GC_SHRINK => "GC_SHRINK",
|
||||
let options = match desc.options_ {
|
||||
GCOptions::Normal => "Normal",
|
||||
GCOptions::Shrink => "Shrink",
|
||||
GCOptions::Shutdown => "Shutdown",
|
||||
};
|
||||
println!(
|
||||
" isZone={}, invocation_kind={}",
|
||||
desc.isZone_, invocation_kind
|
||||
" isZone={}, options={}",
|
||||
desc.isZone_, options
|
||||
);
|
||||
}
|
||||
let _ = stdout().flush();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue