diff --git a/Cargo.lock b/Cargo.lock index 9e66a92747..705f29d548 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -247,9 +247,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5356f1d23ee24a1f785a56d1d1a5f0fd5b0f6a0c0fb2412ce11da71649ab78f6" +checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" [[package]] name = "byte-tools" @@ -1066,9 +1066,9 @@ checksum = "4bac95d9aa0624e7b78187d6fb8ab012b41d9f6f54b1bcb61e61c4845f8357ec" [[package]] name = "indexmap" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" +checksum = "c398b2b113b55809ceb9ee3e753fcbac793f1956663f3c36549c1346015c2afe" dependencies = [ "autocfg 1.0.0", ] @@ -2028,9 +2028,9 @@ dependencies = [ [[package]] name = "rusty_v8" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acb0ad56a57c42009a8d16df5fa94ae882ad0ffe0e88fe1a23b261b3affbccf2" +checksum = "66491597ce62f02c48f0194fc9574ec0b50c648e84947400ba13882394b6d56c" dependencies = [ "bitflags", "cargo_gn", diff --git a/core/Cargo.toml b/core/Cargo.toml index 27fd470860..8acea92832 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -19,7 +19,7 @@ futures = { version = "0.3.5", features = ["thread-pool", "compat"] } lazy_static = "1.4.0" libc = "0.2.71" log = "0.4.8" -rusty_v8 = "0.4.2" +rusty_v8 = "0.5.0" serde_json = "1.0.53" url = "2.1.1" diff --git a/core/bindings.rs b/core/bindings.rs index 877e815797..9b66bfc481 100644 --- a/core/bindings.rs +++ b/core/bindings.rs @@ -239,7 +239,8 @@ pub fn boxed_slice_to_uint8array<'sc>( let backing_store = v8::ArrayBuffer::new_backing_store_from_boxed_slice(buf); let backing_store_shared = backing_store.make_shared(); let ab = v8::ArrayBuffer::with_backing_store(scope, &backing_store_shared); - v8::Uint8Array::new(ab, 0, buf_len).expect("Failed to create UintArray8") + v8::Uint8Array::new(scope, ab, 0, buf_len) + .expect("Failed to create UintArray8") } pub extern "C" fn host_import_module_dynamically_callback( @@ -442,7 +443,7 @@ fn send( let control_backing_store: v8::SharedRef; let control = match v8::Local::::try_from(args.get(1)) { Ok(view) => unsafe { - control_backing_store = view.buffer().unwrap().get_backing_store(); + control_backing_store = view.buffer(scope).unwrap().get_backing_store(); get_backing_store_slice( &control_backing_store, view.byte_offset(), @@ -458,7 +459,7 @@ fn send( let mut buf_iter = (2..args.length()).map(|idx| { v8::Local::::try_from(args.get(idx)) - .map(ZeroCopyBuf::new) + .map(|view| ZeroCopyBuf::new(scope, view)) .map_err(|err| { let msg = format!("Invalid argument at position {}: {}", idx, err); let msg = v8::String::new(scope, &msg).unwrap(); @@ -575,7 +576,7 @@ fn eval_context( if maybe_script.is_none() { assert!(tc.has_caught()); - let exception = tc.exception().unwrap(); + let exception = tc.exception(scope).unwrap(); output.set( context, @@ -616,7 +617,7 @@ fn eval_context( if result.is_none() { assert!(tc.has_caught()); - let exception = tc.exception().unwrap(); + let exception = tc.exception(scope).unwrap(); output.set( context, @@ -701,14 +702,15 @@ fn encode( let buf = if text_bytes.is_empty() { let ab = v8::ArrayBuffer::new(scope, 0); - v8::Uint8Array::new(ab, 0, 0).expect("Failed to create UintArray8") + v8::Uint8Array::new(scope, ab, 0, 0).expect("Failed to create UintArray8") } else { let buf_len = text_bytes.len(); let backing_store = v8::ArrayBuffer::new_backing_store_from_boxed_slice(text_bytes); let backing_store_shared = backing_store.make_shared(); let ab = v8::ArrayBuffer::with_backing_store(scope, &backing_store_shared); - v8::Uint8Array::new(ab, 0, buf_len).expect("Failed to create UintArray8") + v8::Uint8Array::new(scope, ab, 0, buf_len) + .expect("Failed to create UintArray8") }; rv.set(buf.into()) @@ -729,7 +731,7 @@ fn decode( } }; - let backing_store = view.buffer().unwrap().get_backing_store(); + let backing_store = view.buffer(scope).unwrap().get_backing_store(); let buf = unsafe { get_backing_store_slice( &backing_store, diff --git a/core/core_isolate.rs b/core/core_isolate.rs index 5ddc6571bb..984a6a2a6c 100644 --- a/core/core_isolate.rs +++ b/core/core_isolate.rs @@ -315,7 +315,7 @@ impl CoreIsolate { match v8::Script::compile(scope, context, source, Some(&origin)) { Some(script) => script, None => { - let exception = tc.exception().unwrap(); + let exception = tc.exception(scope).unwrap(); return exception_to_err_result(scope, exception); } }; @@ -324,7 +324,7 @@ impl CoreIsolate { Some(_) => Ok(()), None => { assert!(tc.has_caught()); - let exception = tc.exception().unwrap(); + let exception = tc.exception(scope).unwrap(); exception_to_err_result(scope, exception) } } @@ -571,7 +571,7 @@ fn async_op_response<'s>( None => js_recv_cb.call(scope, context, global, &[]), }; - match tc.exception() { + match tc.exception(scope) { None => Ok(()), Some(exception) => exception_to_err_result(scope, exception), } @@ -602,7 +602,7 @@ fn drain_macrotasks<'s>( let is_done = js_macrotask_cb.call(scope, context, global, &[]); - if let Some(exception) = tc.exception() { + if let Some(exception) = tc.exception(scope) { return exception_to_err_result(scope, exception); } diff --git a/core/es_isolate.rs b/core/es_isolate.rs index 059387d7bf..e147984073 100644 --- a/core/es_isolate.rs +++ b/core/es_isolate.rs @@ -133,7 +133,8 @@ impl EsIsolate { if tc.has_caught() { assert!(maybe_module.is_none()); - return exception_to_err_result(scope, tc.exception().unwrap()); + let e = tc.exception(scope).unwrap(); + return exception_to_err_result(scope, e); } let module = maybe_module.unwrap(); @@ -198,7 +199,7 @@ impl EsIsolate { match result { Some(_) => Ok(()), None => { - let exception = tc.exception().unwrap(); + let exception = tc.exception(scope).unwrap(); exception_to_err_result(scope, exception) } } @@ -352,7 +353,7 @@ impl EsIsolate { let resolver = resolver_handle.get(scope).unwrap(); resolver_handle.reset(scope); - let mut module = { + let module = { let state = state_rc.borrow(); let info = state .modules diff --git a/core/zero_copy_buf.rs b/core/zero_copy_buf.rs index 25c468ffe8..be61d5f984 100644 --- a/core/zero_copy_buf.rs +++ b/core/zero_copy_buf.rs @@ -18,8 +18,11 @@ pub struct ZeroCopyBuf { unsafe impl Send for ZeroCopyBuf {} impl ZeroCopyBuf { - pub fn new(view: v8::Local) -> Self { - let backing_store = view.buffer().unwrap().get_backing_store(); + pub fn new<'s>( + scope: &mut impl v8::ToLocal<'s>, + view: v8::Local, + ) -> Self { + let backing_store = view.buffer(scope).unwrap().get_backing_store(); let byte_offset = view.byte_offset(); let byte_length = view.byte_length(); Self {