mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 15:06:54 -05:00
Upgrade rusty_v8 to 0.2.0 (#3764)
This commit is contained in:
parent
74e6eb14dd
commit
9f1e4237a5
5 changed files with 28 additions and 38 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -303,7 +303,7 @@ dependencies = [
|
|||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rusty_v8 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rusty_v8 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tokio 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1155,7 +1155,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rusty_v8"
|
||||
version = "0.1.1"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1906,7 +1906,7 @@ dependencies = [
|
|||
"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
|
||||
"checksum rustls 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b25a18b1bf7387f0145e7f8324e700805aade3842dd3db2e74e4cdeb4677c09e"
|
||||
"checksum rustls-native-certs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "51ffebdbb48c14f84eba0b715197d673aff1dd22cc1007ca647e28483bbcc307"
|
||||
"checksum rusty_v8 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d0a2e0cf49117db64379701eb50d12ab9ec3ca8292047f140c13c5174599441"
|
||||
"checksum rusty_v8 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4df92150d6a81664988f755ecb39f5ed0b89722fd90990a0da9f28c4b1d2a48a"
|
||||
"checksum rustyline 5.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a23cb19702a8d6afb6edb3c842386e680d4883760e0df74e6848e23c2a87a635"
|
||||
"checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8"
|
||||
"checksum schannel 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "87f550b06b6cba9c8b8be3ee73f391990116bf527450d2556e9b9ce263b9a021"
|
||||
|
|
|
@ -21,7 +21,7 @@ libc = "0.2.66"
|
|||
log = "0.4.8"
|
||||
serde_json = "1.0.44"
|
||||
url = "2.1.0"
|
||||
rusty_v8 = "0.1.1"
|
||||
rusty_v8 = "0.2.0"
|
||||
|
||||
[[example]]
|
||||
name = "deno_core_http_bench"
|
||||
|
|
|
@ -9,8 +9,6 @@ use v8::MapFnTo;
|
|||
|
||||
use std::convert::TryFrom;
|
||||
use std::option::Option;
|
||||
use std::ptr;
|
||||
use std::slice;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref EXTERNAL_REFERENCES: v8::ExternalReferences =
|
||||
|
@ -186,9 +184,10 @@ pub fn boxed_slice_to_uint8array<'sc>(
|
|||
) -> v8::Local<'sc, v8::Uint8Array> {
|
||||
assert!(!buf.is_empty());
|
||||
let buf_len = buf.len();
|
||||
let backing_store =
|
||||
unsafe { &mut v8::ArrayBuffer::new_backing_store_from_boxed_slice(buf) };
|
||||
let ab = v8::ArrayBuffer::new_with_backing_store(scope, backing_store);
|
||||
let backing_store = v8::ArrayBuffer::new_backing_store_from_boxed_slice(buf);
|
||||
let mut backing_store_shared = backing_store.make_shared();
|
||||
let ab =
|
||||
v8::ArrayBuffer::with_backing_store(scope, &mut backing_store_shared);
|
||||
v8::Uint8Array::new(ab, 0, buf_len).expect("Failed to create UintArray8")
|
||||
}
|
||||
|
||||
|
@ -397,13 +396,10 @@ fn send(
|
|||
|
||||
let control = match v8::Local::<v8::ArrayBufferView>::try_from(args.get(1)) {
|
||||
Ok(view) => {
|
||||
let mut backing_store = view.buffer().unwrap().get_backing_store();
|
||||
let backing_store_ptr = backing_store.data() as *mut _ as *mut u8;
|
||||
let view_ptr = unsafe { backing_store_ptr.add(view.byte_offset()) };
|
||||
let view_len = view.byte_length();
|
||||
unsafe { slice::from_raw_parts(view_ptr, view_len) }
|
||||
let backing_store = view.buffer().unwrap().get_backing_store();
|
||||
unsafe { &**backing_store.get() }
|
||||
}
|
||||
Err(..) => unsafe { slice::from_raw_parts(ptr::null(), 0) },
|
||||
Err(..) => &[],
|
||||
};
|
||||
|
||||
let zero_copy: Option<PinnedBuf> =
|
||||
|
@ -599,7 +595,7 @@ fn shared_getter(
|
|||
|
||||
// Lazily initialize the persistent external ArrayBuffer.
|
||||
if deno_isolate.shared_ab.is_empty() {
|
||||
let ab = v8::SharedArrayBuffer::new_with_backing_store(
|
||||
let ab = v8::SharedArrayBuffer::with_backing_store(
|
||||
scope,
|
||||
deno_isolate.shared.get_backing_store(),
|
||||
);
|
||||
|
|
|
@ -27,8 +27,6 @@ use std::future::Future;
|
|||
use std::ops::{Deref, DerefMut};
|
||||
use std::option::Option;
|
||||
use std::pin::Pin;
|
||||
use std::ptr::NonNull;
|
||||
use std::slice;
|
||||
use std::sync::{Arc, Mutex, Once};
|
||||
use std::task::Context;
|
||||
use std::task::Poll;
|
||||
|
@ -38,24 +36,22 @@ use std::task::Poll;
|
|||
/// behaves much like an Arc<[u8]>, although a PinnedBuf currently can't be
|
||||
/// cloned.
|
||||
pub struct PinnedBuf {
|
||||
data_ptr: NonNull<u8>,
|
||||
data_len: usize,
|
||||
#[allow(unused)]
|
||||
backing_store: v8::SharedRef<v8::BackingStore>,
|
||||
byte_offset: usize,
|
||||
byte_length: usize,
|
||||
}
|
||||
|
||||
unsafe impl Send for PinnedBuf {}
|
||||
|
||||
impl PinnedBuf {
|
||||
pub fn new(view: v8::Local<v8::ArrayBufferView>) -> Self {
|
||||
let mut backing_store = view.buffer().unwrap().get_backing_store();
|
||||
let backing_store_ptr = backing_store.data() as *mut _ as *mut u8;
|
||||
let view_ptr = unsafe { backing_store_ptr.add(view.byte_offset()) };
|
||||
let view_len = view.byte_length();
|
||||
let backing_store = view.buffer().unwrap().get_backing_store();
|
||||
let byte_offset = view.byte_offset();
|
||||
let byte_length = view.byte_length();
|
||||
Self {
|
||||
data_ptr: NonNull::new(view_ptr).unwrap(),
|
||||
data_len: view_len,
|
||||
backing_store,
|
||||
byte_offset,
|
||||
byte_length,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,13 +59,15 @@ impl PinnedBuf {
|
|||
impl Deref for PinnedBuf {
|
||||
type Target = [u8];
|
||||
fn deref(&self) -> &[u8] {
|
||||
unsafe { slice::from_raw_parts(self.data_ptr.as_ptr(), self.data_len) }
|
||||
let buf = unsafe { &**self.backing_store.get() };
|
||||
&buf[self.byte_offset..self.byte_offset + self.byte_length]
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for PinnedBuf {
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
unsafe { slice::from_raw_parts_mut(self.data_ptr.as_ptr(), self.data_len) }
|
||||
let buf = unsafe { &mut **self.backing_store.get() };
|
||||
&mut buf[self.byte_offset..self.byte_offset + self.byte_length]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,9 @@ impl SharedQueue {
|
|||
let buf = buf.into_boxed_slice();
|
||||
let buf =
|
||||
unsafe { v8::SharedArrayBuffer::new_backing_store_from_boxed_slice(buf) };
|
||||
let mut q = Self { buf };
|
||||
let mut q = Self {
|
||||
buf: buf.make_shared(),
|
||||
};
|
||||
q.reset();
|
||||
q
|
||||
}
|
||||
|
@ -55,17 +57,11 @@ impl SharedQueue {
|
|||
}
|
||||
|
||||
pub fn bytes(&self) -> &[u8] {
|
||||
unsafe {
|
||||
// This is quite bad. The rusty_v8 issue that makes it necessitates it
|
||||
// just barely missed the rusty_v8 v0.1.1 release cutoff.
|
||||
#[allow(clippy::cast_ref_to_mut)]
|
||||
let self_mut = &mut *(self as *const _ as *mut Self);
|
||||
self_mut.bytes_mut()
|
||||
}
|
||||
unsafe { &*self.buf.get() }
|
||||
}
|
||||
|
||||
pub fn bytes_mut(&mut self) -> &mut [u8] {
|
||||
self.buf.data_bytes()
|
||||
unsafe { &mut *self.buf.get() }
|
||||
}
|
||||
|
||||
fn reset(&mut self) {
|
||||
|
|
Loading…
Reference in a new issue