mirror of
https://github.com/denoland/deno.git
synced 2025-09-28 05:04:48 +00:00
Move buffers between V8 and native
* send()/recv() now operate on TypedArrays rather than ArrayBuffers. * Remove a copy (through ArrayBuffer.slice()) from the send path. * Remove a copy (through v8::ArrayBuffer::New()) from the return path. * After moving a buffer from JS to native, the ArrayBuffer object and it's views are made inaccessible ('neutered'). * `struct deno_buf` now holds two [ptr, length] tuples, one for the actual memory allocation, and one for the logical data contained therein. This is necessary because flatbuffers fills it's buffer bottom-up, so the serialized blob doesn't start at beginning of the buffer, but somewhere in the middle.
This commit is contained in:
parent
bbcd4c8dd3
commit
24b0e91d80
12 changed files with 438 additions and 70 deletions
13
src/main.rs
13
src/main.rs
|
@ -9,8 +9,10 @@ use std::ptr;
|
|||
|
||||
#[repr(C)]
|
||||
struct deno_buf {
|
||||
data: *const c_char,
|
||||
len: c_int, // TODO(ry) should be size_t.
|
||||
alloc_ptr: *mut u8,
|
||||
alloc_len: usize,
|
||||
data_ptr: *mut u8,
|
||||
data_len: usize,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -120,9 +122,10 @@ fn main() {
|
|||
|
||||
let mut d = Deno::new();
|
||||
|
||||
d.execute("deno_main.js", "denoMain();")
|
||||
.unwrap_or_else(|err| {
|
||||
d.execute("deno_main.js", "denoMain();").unwrap_or_else(
|
||||
|err| {
|
||||
println!("Error {}\n", err);
|
||||
std::process::exit(1);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue