diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/Cargo.toml | 2 | ||||
-rw-r--r-- | core/bindings.rs | 18 | ||||
-rw-r--r-- | core/core_isolate.rs | 8 | ||||
-rw-r--r-- | core/es_isolate.rs | 7 | ||||
-rw-r--r-- | core/zero_copy_buf.rs | 7 |
5 files changed, 24 insertions, 18 deletions
diff --git a/core/Cargo.toml b/core/Cargo.toml index 27fd47086..8acea9283 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 877e81579..9b66bfc48 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<v8::BackingStore>; let control = match v8::Local::<v8::ArrayBufferView>::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::<v8::ArrayBufferView>::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 5ddc6571b..984a6a2a6 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 059387d7b..e14798407 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 25c468ffe..be61d5f98 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<v8::ArrayBufferView>) -> Self { - let backing_store = view.buffer().unwrap().get_backing_store(); + pub fn new<'s>( + scope: &mut impl v8::ToLocal<'s>, + view: v8::Local<v8::ArrayBufferView>, + ) -> Self { + let backing_store = view.buffer(scope).unwrap().get_backing_store(); let byte_offset = view.byte_offset(); let byte_length = view.byte_length(); Self { |