Fix errors

This commit is contained in:
sagudev 2021-03-12 16:26:27 +01:00
parent 05d5eff26c
commit 425057c432
4 changed files with 11 additions and 20 deletions

View file

@ -29,7 +29,7 @@ use js::rust::wrappers::JS_FireOnNewGlobalObject;
use js::rust::wrappers::RUST_SYMBOL_TO_JSID;
use js::rust::wrappers::{JS_DefineProperty, JS_DefineProperty5};
use js::rust::wrappers::{JS_DefineProperty3, JS_DefineProperty4, JS_DefinePropertyById5};
use js::rust::wrappers::{JS_LinkConstructorAndPrototype, JS_NewObjectWithUniqueType};
use js::rust::wrappers::{JS_LinkConstructorAndPrototype, JS_NewObjectWithGivenProto};
use js::rust::{define_methods, define_properties, get_object_class};
use js::rust::{HandleObject, HandleValue, MutableHandleObject, RealmOptions};
use std::convert::TryFrom;
@ -316,7 +316,7 @@ pub fn create_object(
mut rval: MutableHandleObject,
) {
unsafe {
rval.set(JS_NewObjectWithUniqueType(*cx, class, proto));
rval.set(JS_NewObjectWithGivenProto(*cx, class, proto));
}
assert!(!rval.is_null());
define_guarded_methods(cx, rval.handle(), methods, global);

View file

@ -66,7 +66,6 @@ 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};
@ -446,16 +445,14 @@ impl FetchResponseListener for ClassicContext {
fetch_options: self.fetch_options.clone(),
});
let mut token = ptr::null_mut();
unsafe {
assert!(CompileOffThread1(
assert!(!CompileOffThread1(
*cx,
options.ptr as *const _,
&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,
));
).is_null());
}
} else {
let load = ScriptOrigin::external(

View file

@ -45,14 +45,14 @@ use js::jsapi::Handle as RawHandle;
use js::jsapi::HandleObject;
use js::jsapi::HandleValue as RawHandleValue;
use js::jsapi::Value;
use js::jsapi::{CompileModule1, ExceptionStackBehavior, FinishDynamicModuleImport};
use js::jsapi::{CompileModule1, ExceptionStackBehavior, FinishDynamicModuleImport_NoTLA};
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::{ThrowOnModuleEvaluationFailure, ModuleInstantiate};
use js::jsval::{JSVal, PrivateValue, UndefinedValue};
use js::rust::jsapi_wrapped::{GetArrayLength, JS_GetElement};
use js::rust::jsapi_wrapped::{GetRequestedModuleSpecifier, JS_GetPendingException};
@ -505,7 +505,7 @@ impl ModuleTree {
let _ac = JSAutoRealm::new(*global.get_cx(), *global.reflector().get_jsobject());
unsafe {
if !ModuleEvaluate(*global.get_cx(), module_record) {
if !ThrowOnModuleEvaluationFailure(*global.get_cx(), module_record) {
warn!("fail to evaluate module");
rooted!(in(*global.get_cx()) let mut exception = UndefinedValue());
@ -1024,7 +1024,7 @@ impl ModuleOwner {
debug!("Finishing dynamic import for {:?}", module_identity);
unsafe {
FinishDynamicModuleImport(
FinishDynamicModuleImport_NoTLA(
*cx,
status,
module.referencing_private.handle(),

View file

@ -56,7 +56,7 @@ use js::jsapi::{
};
use js::jsapi::{HandleObject, Heap, JobQueue};
use js::jsapi::{JSContext as RawJSContext, JSTracer, SetDOMCallbacks, SetGCSliceCallback};
use js::jsapi::{JSGCMode, JSGCParamKey, JS_SetGCParameter, JS_SetGlobalJitCompilerOption};
use js::jsapi::{JSGCParamKey, JS_SetGCParameter, JS_SetGlobalJitCompilerOption};
use js::jsapi::{
JSJitCompilerOption, JS_SetOffthreadIonCompilationEnabled, JS_SetParallelParsingEnabled,
};
@ -591,14 +591,8 @@ unsafe fn new_rt_and_cx_with_parent(
.unwrap_or(u32::max_value()),
);
// NOTE: This is disabled above, so enabling it here will do nothing for now.
let js_gc_mode = if pref!(js.mem.gc.incremental.enabled) {
JSGCMode::JSGC_MODE_INCREMENTAL
} else if pref!(js.mem.gc.per_zone.enabled) {
JSGCMode::JSGC_MODE_ZONE
} else {
JSGCMode::JSGC_MODE_GLOBAL
};
JS_SetGCParameter(cx, JSGCParamKey::JSGC_MODE, js_gc_mode as u32);
JS_SetGCParameter(cx, JSGCParamKey::JSGC_INCREMENTAL_GC_ENABLED, pref!(js.mem.gc.incremental.enabled) as u32);
JS_SetGCParameter(cx, JSGCParamKey::JSGC_PER_ZONE_GC_ENABLED, pref!(js.mem.gc.per_zone.enabled) as u32);
if let Some(val) = in_range(pref!(js.mem.gc.incremental.slice_ms), 0, 100_000) {
JS_SetGCParameter(cx, JSGCParamKey::JSGC_SLICE_TIME_BUDGET_MS, val as u32);
}