1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-05 13:59:01 -05:00

chore: update rusty_v8 to 0.56.0 (#16814)

Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
This commit is contained in:
Bartek Iwańczuk 2022-11-26 16:35:46 +01:00 committed by Yoshiya Hinosawa
parent bcbcc72996
commit e095c54422
No known key found for this signature in database
GPG key ID: 0E8BFAA8A5B4E92B
3 changed files with 36 additions and 15 deletions

5
Cargo.lock generated
View file

@ -5387,14 +5387,13 @@ dependencies = [
[[package]]
name = "v8"
version = "0.55.0"
version = "0.56.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46cd4f562bce7520fbb511850c5488366264caf346be221cf7e908f51ac33dbc"
checksum = "4182d3112bf61cc6bbc4839b728c27d5aa5c6b12ee26b91b039308715a61c208"
dependencies = [
"bitflags",
"fslock",
"lazy_static",
"libc",
"which",
]

View file

@ -40,7 +40,7 @@ license = "MIT"
repository = "https://github.com/denoland/deno"
[workspace.dependencies]
v8 = { version = "0.55.0", default-features = false }
v8 = { version = "0.56.0", default-features = false }
deno_ast = { version = "0.21.0", features = ["transpiling"] }
deno_core = { version = "0.161.0", path = "./core" }

View file

@ -458,9 +458,13 @@ fn codegen_u8_slice(core: &TokenStream2, idx: usize) -> TokenStream2 {
match #core::v8::Local::<#core::v8::ArrayBuffer>::try_from(value) {
Ok(b) => {
let byte_length = b.byte_length();
let store = b.data() as *mut u8;
// SAFETY: rust guarantees that lifetime of slice is no longer than the call.
unsafe { ::std::slice::from_raw_parts_mut(store, byte_length) }
if let Some(data) = b.data() {
let store = data.cast::<u8>().as_ptr();
// SAFETY: rust guarantees that lifetime of slice is no longer than the call.
unsafe { ::std::slice::from_raw_parts_mut(store, byte_length) }
} else {
&mut []
}
},
Err(_) => {
if let Ok(view) = #core::v8::Local::<#core::v8::ArrayBufferView>::try_from(value) {
@ -472,9 +476,13 @@ fn codegen_u8_slice(core: &TokenStream2, idx: usize) -> TokenStream2 {
return #core::_ops::throw_type_error(scope, format!("Expected ArrayBufferView at position {}", #idx));
}
};
let store = buffer.data() as *mut u8;
// SAFETY: rust guarantees that lifetime of slice is no longer than the call.
unsafe { ::std::slice::from_raw_parts_mut(store.add(offset), len) }
if let Some(data) = buffer.data() {
let store = data.cast::<u8>().as_ptr();
// SAFETY: rust guarantees that lifetime of slice is no longer than the call.
unsafe { ::std::slice::from_raw_parts_mut(store.add(offset), len) }
} else {
&mut []
}
} else {
return #core::_ops::throw_type_error(scope, format!("Expected ArrayBufferView at position {}", #idx));
}
@ -487,7 +495,13 @@ fn codegen_u8_ptr(core: &TokenStream2, idx: usize) -> TokenStream2 {
quote! {{
let value = args.get(#idx as i32);
match #core::v8::Local::<#core::v8::ArrayBuffer>::try_from(value) {
Ok(b) => b.data() as *const u8,
Ok(b) => {
if let Some(data) = b.data() {
data.cast::<u8>().as_ptr()
} else {
std::ptr::null::<u8>()
}
},
Err(_) => {
if let Ok(view) = #core::v8::Local::<#core::v8::ArrayBufferView>::try_from(value) {
let offset = view.byte_offset();
@ -497,7 +511,11 @@ fn codegen_u8_ptr(core: &TokenStream2, idx: usize) -> TokenStream2 {
return #core::_ops::throw_type_error(scope, format!("Expected ArrayBufferView at position {}", #idx));
}
};
let store = buffer.data() as *mut u8;
let store = if let Some(data) = buffer.data() {
data.cast::<u8>().as_ptr()
} else {
std::ptr::null_mut::<u8>()
};
unsafe { store.add(offset) }
} else {
return #core::_ops::throw_type_error(scope, format!("Expected ArrayBufferView at position {}", #idx));
@ -517,9 +535,13 @@ fn codegen_u32_mut_slice(core: &TokenStream2, idx: usize) -> TokenStream2 {
return #core::_ops::throw_type_error(scope, format!("Expected Uint32Array at position {}", #idx));
}
};
let store = buffer.data() as *mut u8;
// SAFETY: buffer from Uint32Array. Rust guarantees that lifetime of slice is no longer than the call.
unsafe { ::std::slice::from_raw_parts_mut(store.add(offset) as *mut u32, len / 4) }
if let Some(data) = buffer.data() {
let store = data.cast::<u8>().as_ptr();
// SAFETY: buffer from Uint32Array. Rust guarantees that lifetime of slice is no longer than the call.
unsafe { ::std::slice::from_raw_parts_mut(store.add(offset) as *mut u32, len / 4) }
} else {
&mut []
}
} else {
return #core::_ops::throw_type_error(scope, format!("Expected Uint32Array at position {}", #idx));
}