mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Update mozjs.
This commit is contained in:
parent
4c82d3cb86
commit
5c4939599e
13 changed files with 131 additions and 79 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -3785,7 +3785,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "mozjs"
|
||||
version = "0.14.1"
|
||||
source = "git+https://github.com/servo/rust-mozjs#db90a4651adcc1447d1eb8c4bb13f18ea957d263"
|
||||
source = "git+https://github.com/servo/rust-mozjs#b8122da4ea8a48ea21454e65f42d5b2194a2d311"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"lazy_static",
|
||||
|
@ -3798,7 +3798,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "mozjs_sys"
|
||||
version = "0.68.2"
|
||||
source = "git+https://github.com/servo/mozjs?rev=26a1e8afdb21beec33373ef2a38131272d064bdd#26a1e8afdb21beec33373ef2a38131272d064bdd"
|
||||
source = "git+https://github.com/servo/mozjs?rev=c6c7b5319975a8f0465ce8c17329e74be4cb80b1#c6c7b5319975a8f0465ce8c17329e74be4cb80b1"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cc",
|
||||
|
|
|
@ -23,9 +23,8 @@ use devtools_traits::{AutoMargins, ComputedNodeLayout, TimelineMarkerType};
|
|||
use devtools_traits::{EvaluateJSReply, Modification, NodeInfo, TimelineMarker};
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::wrappers::ObjectClassName;
|
||||
use js::rust::ToString;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use std::ffi::CStr;
|
||||
use std::rc::Rc;
|
||||
use std::str;
|
||||
use uuid::Uuid;
|
||||
|
@ -65,12 +64,11 @@ pub fn handle_evaluate_js(global: &GlobalScope, eval: String, reply: IpcSender<E
|
|||
} else {
|
||||
assert!(rval.is_object());
|
||||
|
||||
rooted!(in(*cx) let obj = rval.to_object());
|
||||
let class_name = CStr::from_ptr(ObjectClassName(*cx, obj.handle()));
|
||||
let class_name = str::from_utf8(class_name.to_bytes()).unwrap();
|
||||
let jsstr = ToString(*cx, rval.handle());
|
||||
let class_name = jsstring_to_str(*cx, jsstr);
|
||||
|
||||
EvaluateJSReply::ActorValue {
|
||||
class: class_name.to_owned(),
|
||||
class: class_name.to_string(),
|
||||
uuid: Uuid::new_v4().to_string(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1884,7 +1884,7 @@ class AttrDefiner(PropertyDefiner):
|
|||
array, name,
|
||||
' JSPropertySpec {\n'
|
||||
' name: JSPropertySpec_Name { string_: %s as *const u8 as *const libc::c_char },\n'
|
||||
' flags: (%s) as u8,\n'
|
||||
' flags_: (%s) as u8,\n'
|
||||
' u: JSPropertySpec_AccessorsOrValue {\n'
|
||||
' accessors: JSPropertySpec_AccessorsOrValue_Accessors {\n'
|
||||
' getter: JSPropertySpec_Accessor {\n'
|
||||
|
@ -2741,7 +2741,7 @@ ensure_expando_object(*cx, obj.handle().into(), expando.handle_mut());
|
|||
# unforgeable holder for those with the right JSClass. Luckily, there
|
||||
# aren't too many globals being created.
|
||||
if descriptor.isGlobal():
|
||||
copyFunc = "JS_CopyPropertiesFrom"
|
||||
copyFunc = "JS_CopyOwnPropertiesAndPrivateFields"
|
||||
else:
|
||||
copyFunc = "JS_InitializePropertiesFromCompatibleNativeObject"
|
||||
copyCode += """\
|
||||
|
@ -2783,7 +2783,6 @@ rooted!(in(*cx) let obj = NewProxyObject(
|
|||
Handle::from_raw(UndefinedHandleValue),
|
||||
proto.get(),
|
||||
ptr::null(),
|
||||
false,
|
||||
));
|
||||
assert!(!obj.is_null());
|
||||
SetProxyReservedSlot(
|
||||
|
@ -6059,7 +6058,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'js::jsapi::JSValueType',
|
||||
'js::jsapi::JS_AtomizeAndPinString',
|
||||
'js::rust::wrappers::JS_CallFunctionValue',
|
||||
'js::rust::wrappers::JS_CopyPropertiesFrom',
|
||||
'js::rust::wrappers::JS_CopyOwnPropertiesAndPrivateFields',
|
||||
'js::rust::wrappers::JS_DefineProperty',
|
||||
'js::rust::wrappers::JS_DefinePropertyById2',
|
||||
'js::jsapi::JS_ForwardGetPropertyTo',
|
||||
|
|
|
@ -56,12 +56,12 @@ 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_NewStringCopyN, JS_StringHasLatin1Chars};
|
||||
use js::jsapi::{IsWindowProxy, JS_DeprecatedStringHasLatin1Chars, JS_NewStringCopyN};
|
||||
use js::jsapi::{
|
||||
JS_GetLatin1StringCharsAndLength, JS_GetTwoByteStringCharsAndLength, JS_IsExceptionPending,
|
||||
};
|
||||
use js::jsval::{ObjectValue, StringValue, UndefinedValue};
|
||||
use js::rust::wrappers::{JS_GetProperty, JS_HasProperty, JS_IsArrayObject};
|
||||
use js::rust::wrappers::{IsArrayObject, JS_GetProperty, JS_HasProperty};
|
||||
use js::rust::{get_object_class, is_dom_class, is_dom_object, maybe_wrap_value, ToString};
|
||||
use js::rust::{HandleId, HandleObject, HandleValue, MutableHandleValue};
|
||||
use num_traits::Float;
|
||||
|
@ -220,7 +220,7 @@ impl FromJSValConvertible for DOMString {
|
|||
/// Convert the given `JSString` to a `DOMString`. Fails if the string does not
|
||||
/// contain valid UTF-16.
|
||||
pub unsafe fn jsstring_to_str(cx: *mut JSContext, s: *mut JSString) -> DOMString {
|
||||
let latin1 = JS_StringHasLatin1Chars(s);
|
||||
let latin1 = JS_DeprecatedStringHasLatin1Chars(s);
|
||||
DOMString::from_string(if latin1 {
|
||||
latin1_to_string(cx, s)
|
||||
} else {
|
||||
|
@ -271,7 +271,7 @@ impl FromJSValConvertible for USVString {
|
|||
debug!("ToString failed");
|
||||
return Err(());
|
||||
}
|
||||
let latin1 = JS_StringHasLatin1Chars(jsstr);
|
||||
let latin1 = JS_DeprecatedStringHasLatin1Chars(jsstr);
|
||||
if latin1 {
|
||||
// FIXME(ajeffrey): Convert directly from DOMString to USVString
|
||||
return Ok(ConversionResult::Success(USVString(String::from(
|
||||
|
@ -317,7 +317,7 @@ impl FromJSValConvertible for ByteString {
|
|||
return Err(());
|
||||
}
|
||||
|
||||
let latin1 = JS_StringHasLatin1Chars(string);
|
||||
let latin1 = JS_DeprecatedStringHasLatin1Chars(string);
|
||||
if latin1 {
|
||||
let mut length = 0;
|
||||
let chars = JS_GetLatin1StringCharsAndLength(cx, ptr::null(), string, &mut length);
|
||||
|
@ -564,7 +564,7 @@ impl<T: DomObject> ToJSValConvertible for DomRoot<T> {
|
|||
/// NodeList).
|
||||
pub unsafe fn is_array_like(cx: *mut JSContext, value: HandleValue) -> bool {
|
||||
let mut is_array = false;
|
||||
assert!(JS_IsArrayObject(cx, value, &mut is_array));
|
||||
assert!(IsArrayObject(cx, value, &mut is_array));
|
||||
if is_array {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -116,6 +116,7 @@ unsafe fn write_blob(
|
|||
unsafe extern "C" fn read_callback(
|
||||
cx: *mut JSContext,
|
||||
r: *mut JSStructuredCloneReader,
|
||||
_policy: *const CloneDataPolicy,
|
||||
tag: u32,
|
||||
_data: u32,
|
||||
closure: *mut raw::c_void,
|
||||
|
@ -143,6 +144,7 @@ unsafe extern "C" fn write_callback(
|
|||
cx: *mut JSContext,
|
||||
w: *mut JSStructuredCloneWriter,
|
||||
obj: RawHandleObject,
|
||||
_same_process_scope_required: *mut bool,
|
||||
closure: *mut raw::c_void,
|
||||
) -> bool {
|
||||
if let Ok(blob) = root_from_object::<Blob>(*obj, cx) {
|
||||
|
@ -216,6 +218,7 @@ unsafe extern "C" fn free_transfer_callback(
|
|||
unsafe extern "C" fn can_transfer_callback(
|
||||
cx: *mut JSContext,
|
||||
obj: RawHandleObject,
|
||||
_same_process_scope_required: *mut bool,
|
||||
_closure: *mut raw::c_void,
|
||||
) -> bool {
|
||||
if let Ok(_port) = root_from_object::<MessagePort>(*obj, cx) {
|
||||
|
@ -224,7 +227,21 @@ unsafe extern "C" fn can_transfer_callback(
|
|||
false
|
||||
}
|
||||
|
||||
unsafe extern "C" fn report_error_callback(_cx: *mut JSContext, _errorid: u32) {}
|
||||
unsafe extern "C" fn report_error_callback(
|
||||
_cx: *mut JSContext,
|
||||
_errorid: u32,
|
||||
_closure: *mut ::std::os::raw::c_void,
|
||||
_error_message: *const ::std::os::raw::c_char,
|
||||
) {
|
||||
}
|
||||
|
||||
unsafe extern "C" fn sab_cloned_callback(
|
||||
_cx: *mut JSContext,
|
||||
_receiving: bool,
|
||||
_closure: *mut ::std::os::raw::c_void,
|
||||
) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
static STRUCTURED_CLONE_CALLBACKS: JSStructuredCloneCallbacks = JSStructuredCloneCallbacks {
|
||||
read: Some(read_callback),
|
||||
|
@ -234,6 +251,7 @@ static STRUCTURED_CLONE_CALLBACKS: JSStructuredCloneCallbacks = JSStructuredClon
|
|||
writeTransfer: Some(write_transfer_callback),
|
||||
freeTransfer: Some(free_transfer_callback),
|
||||
canTransfer: Some(can_transfer_callback),
|
||||
sabCloned: Some(sab_cloned_callback),
|
||||
};
|
||||
|
||||
/// A data holder for results from, and inputs to, structured-data read/write operations.
|
||||
|
@ -286,15 +304,15 @@ pub fn write(
|
|||
);
|
||||
let scdata = &mut ((*scbuf).data_);
|
||||
let policy = CloneDataPolicy {
|
||||
// TODO: SAB?
|
||||
sharedArrayBuffer_: false,
|
||||
allowIntraClusterClonableSharedObjects_: false,
|
||||
allowSharedMemoryObjects_: false,
|
||||
};
|
||||
let result = JS_WriteStructuredClone(
|
||||
*cx,
|
||||
message,
|
||||
scdata,
|
||||
StructuredCloneScope::DifferentProcess,
|
||||
policy,
|
||||
&policy,
|
||||
&STRUCTURED_CLONE_CALLBACKS,
|
||||
sc_holder_ptr as *mut raw::c_void,
|
||||
val.handle(),
|
||||
|
@ -361,8 +379,9 @@ pub fn read(
|
|||
JS_STRUCTURED_CLONE_VERSION,
|
||||
StructuredCloneScope::DifferentProcess,
|
||||
rval,
|
||||
CloneDataPolicy {
|
||||
sharedArrayBuffer_: false,
|
||||
&CloneDataPolicy {
|
||||
allowIntraClusterClonableSharedObjects_: false,
|
||||
allowSharedMemoryObjects_: false,
|
||||
},
|
||||
&STRUCTURED_CLONE_CALLBACKS,
|
||||
sc_holder_ptr as *mut raw::c_void,
|
||||
|
|
|
@ -16,7 +16,7 @@ use crate::dom::bindings::str::DOMString;
|
|||
use crate::dom::bindings::trace::trace_object;
|
||||
use crate::dom::windowproxy;
|
||||
use crate::script_runtime::JSContext as SafeJSContext;
|
||||
use js::conversions::{jsstr_to_string, ToJSValConvertible};
|
||||
use js::conversions::ToJSValConvertible;
|
||||
use js::glue::{CallJitGetterOp, CallJitMethodOp, CallJitSetterOp, IsWrapper};
|
||||
use js::glue::{GetCrossCompartmentWrapper, JS_GetReservedSlot, WrapperNew};
|
||||
use js::glue::{UnwrapObjectDynamic, UnwrapObjectStatic, RUST_JSID_TO_INT, RUST_JSID_TO_STRING};
|
||||
|
@ -27,15 +27,15 @@ use js::jsapi::HandleId as RawHandleId;
|
|||
use js::jsapi::HandleObject as RawHandleObject;
|
||||
use js::jsapi::MutableHandleIdVector as RawMutableHandleIdVector;
|
||||
use js::jsapi::MutableHandleObject as RawMutableHandleObject;
|
||||
use js::jsapi::{AtomToLinearString, GetLinearStringCharAt, GetLinearStringLength};
|
||||
use js::jsapi::{CallArgs, DOMCallbacks, GetNonCCWObjectGlobal};
|
||||
use js::jsapi::{Heap, JSAutoRealm, JSContext, JS_FreezeObject};
|
||||
use js::jsapi::{JSAtom, JS_IsExceptionPending, JS_IsGlobalObject};
|
||||
use js::jsapi::{JSJitInfo, JSObject, JSTracer, JSWrapObjectCallbacks};
|
||||
use js::jsapi::{JS_EnumerateStandardClasses, JS_GetLatin1StringCharsAndLength};
|
||||
use js::jsapi::{JS_IsExceptionPending, JS_IsGlobalObject};
|
||||
use js::jsapi::{
|
||||
JS_ResolveStandardClass, JS_StringHasLatin1Chars, ObjectOpResult, StringIsArrayIndex1,
|
||||
StringIsArrayIndex2,
|
||||
JS_DeprecatedStringHasLatin1Chars, JS_ResolveStandardClass, ObjectOpResult, StringIsArrayIndex,
|
||||
};
|
||||
use js::jsapi::{JS_EnumerateStandardClasses, JS_GetLatin1StringCharsAndLength};
|
||||
use js::jsval::{JSVal, UndefinedValue};
|
||||
use js::rust::wrappers::JS_DeletePropertyById;
|
||||
use js::rust::wrappers::JS_ForwardGetPropertyTo;
|
||||
|
@ -191,7 +191,7 @@ 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> {
|
||||
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);
|
||||
|
@ -201,7 +201,28 @@ pub unsafe fn get_array_index_from_id(cx: *mut JSContext, id: HandleId) -> Optio
|
|||
return None;
|
||||
}
|
||||
|
||||
let s = jsstr_to_string(cx, RUST_JSID_TO_STRING(raw_id));
|
||||
let atom = RUST_JSID_TO_STRING(raw_id) as *mut JSAtom;
|
||||
let s = AtomToLinearString(atom);
|
||||
if GetLinearStringLength(s) == 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
let chars = [GetLinearStringCharAt(s, 0)];
|
||||
let first_char = char::decode_utf16(chars.iter().cloned())
|
||||
.next()
|
||||
.map_or('\0', |r| r.unwrap_or('\0'));
|
||||
if first_char < 'a' || first_char > 'z' {
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut i = 0;
|
||||
if StringIsArrayIndex(s, &mut i) {
|
||||
Some(i)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
/*let s = jsstr_to_string(cx, RUST_JSID_TO_STRING(raw_id));
|
||||
if s.len() == 0 {
|
||||
return None;
|
||||
}
|
||||
|
@ -225,7 +246,7 @@ pub unsafe fn get_array_index_from_id(cx: *mut JSContext, id: HandleId) -> Optio
|
|||
Some(i)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/// Find the enum equivelent of a string given by `v` in `pairs`.
|
||||
|
@ -436,7 +457,7 @@ pub unsafe extern "C" fn resolve_global(
|
|||
}
|
||||
|
||||
let string = RUST_JSID_TO_STRING(id);
|
||||
if !JS_StringHasLatin1Chars(string) {
|
||||
if !JS_DeprecatedStringHasLatin1Chars(string) {
|
||||
*rval = false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -66,6 +66,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};
|
||||
|
@ -445,6 +446,7 @@ impl FetchResponseListener for ClassicContext {
|
|||
fetch_options: self.fetch_options.clone(),
|
||||
});
|
||||
|
||||
let mut token = ptr::null_mut();
|
||||
unsafe {
|
||||
assert!(CompileOffThread1(
|
||||
*cx,
|
||||
|
@ -452,6 +454,7 @@ impl FetchResponseListener for ClassicContext {
|
|||
&mut transform_str_to_source_text(&context.script_text) as *mut _,
|
||||
Some(off_thread_compilation_callback),
|
||||
Box::into_raw(context) as *mut c_void,
|
||||
&mut token,
|
||||
));
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -36,7 +36,7 @@ use js::jsapi::JSAutoRealm;
|
|||
use js::jsapi::JSObject;
|
||||
use js::jsapi::JS_ClearPendingException;
|
||||
use js::jsapi::JS_IsExceptionPending;
|
||||
use js::jsapi::JS_NewArrayObject;
|
||||
use js::jsapi::NewArrayObject;
|
||||
use js::jsval::JSVal;
|
||||
use js::jsval::ObjectValue;
|
||||
use js::jsval::UndefinedValue;
|
||||
|
@ -333,7 +333,7 @@ impl PaintWorkletGlobalScope {
|
|||
.collect();
|
||||
let arguments_value_array =
|
||||
unsafe { HandleValueArray::from_rooted_slice(&*arguments_value_vec) };
|
||||
rooted!(in(*cx) let argument_object = unsafe { JS_NewArrayObject(*cx, &arguments_value_array) });
|
||||
rooted!(in(*cx) let argument_object = unsafe { NewArrayObject(*cx, &arguments_value_array) });
|
||||
|
||||
let args_slice = [
|
||||
ObjectValue(rendering_context.reflector().get_jsobject().get()),
|
||||
|
|
|
@ -112,7 +112,7 @@ fn typedarray_elem_size(typeid: Type) -> usize {
|
|||
Type::Int32 | Type::Uint32 | Type::Float32 => 4,
|
||||
Type::Int64 | Type::Float64 => 8,
|
||||
Type::BigInt64 | Type::BigUint64 => 8,
|
||||
Type::MaxTypedArrayViewType => unreachable!(),
|
||||
Type::Simd128 | Type::MaxTypedArrayViewType => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5042,6 +5042,7 @@ fn array_buffer_type_to_sized_type(type_: Type) -> Option<SizedDataType> {
|
|||
Type::BigInt64 |
|
||||
Type::BigUint64 |
|
||||
Type::MaxTypedArrayViewType |
|
||||
Type::Int64 => None,
|
||||
Type::Int64 |
|
||||
Type::Simd128 => None,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#![feature(assoc_char_funcs)]
|
||||
#![feature(const_fn)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(drain_filter)]
|
||||
|
|
|
@ -45,17 +45,17 @@ use js::jsapi::Handle as RawHandle;
|
|||
use js::jsapi::HandleObject;
|
||||
use js::jsapi::HandleValue as RawHandleValue;
|
||||
use js::jsapi::Value;
|
||||
use js::jsapi::{CompileModuleDontInflate, ExceptionStackBehavior, FinishDynamicModuleImport};
|
||||
use js::jsapi::{CompileModule1, ExceptionStackBehavior, FinishDynamicModuleImport};
|
||||
use js::jsapi::{DynamicImportStatus, SetModuleDynamicImportHook, SetScriptPrivateReferenceHooks};
|
||||
use js::jsapi::{GetModuleResolveHook, JSRuntime, SetModuleResolveHook};
|
||||
use js::jsapi::{GetRequestedModules, SetModuleMetadataHook};
|
||||
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::{SetModuleDynamicImportHook, SetScriptPrivateReferenceHooks};
|
||||
use js::jsval::{JSVal, PrivateValue, UndefinedValue};
|
||||
use js::rust::jsapi_wrapped::{GetArrayLength, JS_GetElement};
|
||||
use js::rust::jsapi_wrapped::{GetRequestedModuleSpecifier, JS_GetPendingException};
|
||||
use js::rust::jsapi_wrapped::{JS_GetArrayLength, JS_GetElement};
|
||||
use js::rust::transform_str_to_source_text;
|
||||
use js::rust::wrappers::JS_SetPendingException;
|
||||
use js::rust::CompileOptionsWrapper;
|
||||
|
@ -425,7 +425,7 @@ impl ModuleTree {
|
|||
unsafe { CompileOptionsWrapper::new(*global.get_cx(), url.as_str(), 1) };
|
||||
|
||||
unsafe {
|
||||
rooted!(in(*global.get_cx()) let mut module_script = CompileModuleDontInflate(
|
||||
rooted!(in(*global.get_cx()) let mut module_script = CompileModule1(
|
||||
*global.get_cx(),
|
||||
compile_options.ptr,
|
||||
&mut transform_str_to_source_text(&module_script_text),
|
||||
|
@ -558,7 +558,7 @@ impl ModuleTree {
|
|||
|
||||
let mut length = 0;
|
||||
|
||||
if !JS_GetArrayLength(*global.get_cx(), requested_modules.handle(), &mut length) {
|
||||
if !GetArrayLength(*global.get_cx(), requested_modules.handle(), &mut length) {
|
||||
let module_length_error =
|
||||
gen_type_error(&global, "Wrong length of requested modules".to_owned());
|
||||
|
||||
|
@ -995,26 +995,38 @@ impl ModuleOwner {
|
|||
};
|
||||
|
||||
// Ensure any failures related to importing this dynamic module are immediately reported.
|
||||
match (network_error, existing_rethrow_error, execution_err) {
|
||||
let status = 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)
|
||||
JS_SetPendingException(*cx, err.handle(), ExceptionStackBehavior::Capture);
|
||||
DynamicImportStatus::Failed
|
||||
},
|
||||
(None, _, Some(execution_err)) => unsafe {
|
||||
JS_SetPendingException(*cx, execution_err.handle(), ExceptionStackBehavior::Capture)
|
||||
JS_SetPendingException(
|
||||
*cx,
|
||||
execution_err.handle(),
|
||||
ExceptionStackBehavior::Capture,
|
||||
);
|
||||
DynamicImportStatus::Failed
|
||||
},
|
||||
(None, Some(rethrow_error), _) => unsafe {
|
||||
JS_SetPendingException(*cx, rethrow_error.handle(), ExceptionStackBehavior::Capture)
|
||||
JS_SetPendingException(
|
||||
*cx,
|
||||
rethrow_error.handle(),
|
||||
ExceptionStackBehavior::Capture,
|
||||
);
|
||||
DynamicImportStatus::Failed
|
||||
},
|
||||
// do nothing if there's no errors
|
||||
(None, None, None) => {},
|
||||
}
|
||||
(None, None, None) => DynamicImportStatus::Ok,
|
||||
};
|
||||
|
||||
debug!("Finishing dynamic import for {:?}", module_identity);
|
||||
|
||||
unsafe {
|
||||
FinishDynamicModuleImport(
|
||||
*cx,
|
||||
status,
|
||||
module.referencing_private.handle(),
|
||||
module.specifier.handle(),
|
||||
module.promise.reflector().get_jsobject().into_handle(),
|
||||
|
|
|
@ -50,17 +50,17 @@ use js::jsapi::PromiseUserInputEventHandlingState;
|
|||
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,
|
||||
JS_RequestInterruptCallback, JS_SetGCCallback,
|
||||
};
|
||||
use js::jsapi::{HandleObject, Heap, JobQueue};
|
||||
use js::jsapi::{JSContext as RawJSContext, JSTracer, SetDOMCallbacks, SetGCSliceCallback};
|
||||
use js::jsapi::{
|
||||
JSGCInvocationKind, JSGCStatus, JS_AddExtraGCRootsTracer, JS_RequestInterruptCallback,
|
||||
JS_SetGCCallback,
|
||||
};
|
||||
use js::jsapi::{JSGCMode, JSGCParamKey, JS_SetGCParameter, JS_SetGlobalJitCompilerOption};
|
||||
use js::jsapi::{
|
||||
JSJitCompilerOption, JS_SetOffthreadIonCompilationEnabled, JS_SetParallelParsingEnabled,
|
||||
};
|
||||
use js::jsapi::{JSObject, PromiseRejectionHandlingState, SetPreserveWrapperCallback};
|
||||
use js::jsapi::{JSObject, PromiseRejectionHandlingState, SetPreserveWrapperCallbacks};
|
||||
use js::jsapi::{SetJobQueue, SetProcessBuildIdOp, SetPromiseRejectionTrackerCallback};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::panic::wrap_panic;
|
||||
|
@ -478,8 +478,16 @@ unsafe fn new_rt_and_cx_with_parent(
|
|||
unsafe extern "C" fn empty_wrapper_callback(_: *mut RawJSContext, _: HandleObject) -> bool {
|
||||
true
|
||||
}
|
||||
unsafe extern "C" fn empty_has_released_callback(_: HandleObject) -> bool {
|
||||
// fixme: return true when the Drop impl for a DOM object has been invoked
|
||||
false
|
||||
}
|
||||
SetDOMCallbacks(cx, &DOM_CALLBACKS);
|
||||
SetPreserveWrapperCallback(cx, Some(empty_wrapper_callback));
|
||||
SetPreserveWrapperCallbacks(
|
||||
cx,
|
||||
Some(empty_wrapper_callback),
|
||||
Some(empty_has_released_callback),
|
||||
);
|
||||
// Pre barriers aren't working correctly at the moment
|
||||
DisableIncrementalGC(cx);
|
||||
|
||||
|
@ -542,7 +550,7 @@ unsafe fn new_rt_and_cx_with_parent(
|
|||
}
|
||||
cx_opts.set_wasmBaseline_(pref!(js.wasm.baseline.enabled));
|
||||
cx_opts.set_wasmIon_(pref!(js.wasm.ion.enabled));
|
||||
cx_opts.set_extraWarnings_(pref!(js.strict.enabled));
|
||||
cx_opts.set_strictMode_(pref!(js.strict.enabled));
|
||||
// TODO: handle js.strict.debug.enabled
|
||||
// TODO: handle js.throw_on_asmjs_validation_failure (needs new Spidermonkey)
|
||||
JS_SetGlobalJitCompilerOption(
|
||||
|
@ -574,7 +582,6 @@ unsafe fn new_rt_and_cx_with_parent(
|
|||
// TODO: handle js.asyncstack.enabled (needs new Spidermonkey)
|
||||
// TODO: handle js.throw_on_debugee_would_run (needs new Spidermonkey)
|
||||
// TODO: handle js.dump_stack_on_debugee_would_run (needs new Spidermonkey)
|
||||
cx_opts.set_werror_(pref!(js.werror.enabled));
|
||||
// TODO: handle js.shared_memory.enabled
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
|
@ -604,49 +611,39 @@ unsafe fn new_rt_and_cx_with_parent(
|
|||
if let Some(val) = in_range(pref!(js.mem.gc.high_frequency_time_limit_ms), 0, 10_000) {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_HIGH_FREQUENCY_TIME_LIMIT, val as u32);
|
||||
}
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
JSGCParamKey::JSGC_DYNAMIC_MARK_SLICE,
|
||||
pref!(js.mem.gc.dynamic_mark_slice.enabled) as u32,
|
||||
);
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
JSGCParamKey::JSGC_DYNAMIC_HEAP_GROWTH,
|
||||
pref!(js.mem.gc.dynamic_heap_growth.enabled) as u32,
|
||||
);
|
||||
if let Some(val) = in_range(pref!(js.mem.gc.low_frequency_heap_growth), 0, 10_000) {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_LOW_FREQUENCY_HEAP_GROWTH, val as u32);
|
||||
}
|
||||
if let Some(val) = in_range(pref!(js.mem.gc.high_frequency_heap_growth_min), 0, 10_000) {
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
JSGCParamKey::JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN,
|
||||
JSGCParamKey::JSGC_HIGH_FREQUENCY_LARGE_HEAP_GROWTH,
|
||||
val as u32,
|
||||
);
|
||||
}
|
||||
if let Some(val) = in_range(pref!(js.mem.gc.high_frequency_heap_growth_max), 0, 10_000) {
|
||||
JS_SetGCParameter(
|
||||
cx,
|
||||
JSGCParamKey::JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX,
|
||||
JSGCParamKey::JSGC_HIGH_FREQUENCY_SMALL_HEAP_GROWTH,
|
||||
val as u32,
|
||||
);
|
||||
}
|
||||
if let Some(val) = in_range(pref!(js.mem.gc.high_frequency_low_limit_mb), 0, 10_000) {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_HIGH_FREQUENCY_LOW_LIMIT, val as u32);
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_SMALL_HEAP_SIZE_MAX, val as u32);
|
||||
}
|
||||
if let Some(val) = in_range(pref!(js.mem.gc.high_frequency_high_limit_mb), 0, 10_000) {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_HIGH_FREQUENCY_HIGH_LIMIT, val as u32);
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_LARGE_HEAP_SIZE_MIN, val as u32);
|
||||
}
|
||||
if let Some(val) = in_range(pref!(js.mem.gc.allocation_threshold_factor), 0, 10_000) {
|
||||
/*if let Some(val) = in_range(pref!(js.mem.gc.allocation_threshold_factor), 0, 10_000) {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_NON_INCREMENTAL_FACTOR, val as u32);
|
||||
}
|
||||
if let Some(val) = in_range(
|
||||
pref!(js.mem.gc.allocation_threshold_avoid_interrupt_factor),
|
||||
0,
|
||||
10_000,
|
||||
) {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_AVOID_INTERRUPT_FACTOR, val as u32);
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
// JSGC_SMALL_HEAP_INCREMENTAL_LIMIT
|
||||
pref("javascript.options.mem.gc_small_heap_incremental_limit", 140);
|
||||
|
||||
// JSGC_LARGE_HEAP_INCREMENTAL_LIMIT
|
||||
pref("javascript.options.mem.gc_large_heap_incremental_limit", 110);
|
||||
*/
|
||||
if let Some(val) = in_range(pref!(js.mem.gc.empty_chunk_count_min), 0, 10_000) {
|
||||
JS_SetGCParameter(cx, JSGCParamKey::JSGC_MIN_EMPTY_CHUNK_COUNT, val as u32);
|
||||
}
|
||||
|
@ -796,6 +793,7 @@ unsafe extern "C" fn gc_slice_callback(
|
|||
unsafe extern "C" fn debug_gc_callback(
|
||||
_cx: *mut RawJSContext,
|
||||
status: JSGCStatus,
|
||||
_reason: GCReason,
|
||||
_data: *mut os::raw::c_void,
|
||||
) {
|
||||
match status {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue