diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2018-10-23 19:39:31 -0400 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-10-24 14:52:38 -0700 |
commit | fd68f85ce8cfbb036f0bc2c532f423d8ffa78289 (patch) | |
tree | dc6ed9f2fad00efdd5ae5468b4abf3631d54bd24 /src | |
parent | 3438dbe3509da8e8674dd803e8ecdc92e30f7d61 (diff) |
libdeno: deno_new should take a snapshot parameter.
Diffstat (limited to 'src')
-rw-r--r-- | src/isolate.rs | 5 | ||||
-rw-r--r-- | src/libdeno.rs | 6 | ||||
-rw-r--r-- | src/main.rs | 1 | ||||
-rw-r--r-- | src/snapshot.cc | 18 | ||||
-rw-r--r-- | src/snapshot.rs | 5 |
5 files changed, 30 insertions, 5 deletions
diff --git a/src/isolate.rs b/src/isolate.rs index 24f9e6adf..df13fca96 100644 --- a/src/isolate.rs +++ b/src/isolate.rs @@ -8,6 +8,7 @@ use deno_dir; use errors::DenoError; use flags; use libdeno; +use snapshot; use futures::Future; use libc::c_void; @@ -109,7 +110,9 @@ impl Isolate { unsafe { libdeno::deno_init() }; }); - let libdeno_isolate = unsafe { libdeno::deno_new(pre_dispatch) }; + let libdeno_isolate = unsafe { + libdeno::deno_new(snapshot::deno_snapshot.clone(), pre_dispatch) + }; // This channel handles sending async messages back to the runtime. let (tx, rx) = mpsc::channel::<(i32, Buf)>(); diff --git a/src/libdeno.rs b/src/libdeno.rs index 732c78a21..812cd4620 100644 --- a/src/libdeno.rs +++ b/src/libdeno.rs @@ -1,6 +1,4 @@ // Copyright 2018 the Deno authors. All rights reserved. MIT license. -#![allow(dead_code)] -extern crate libc; use libc::c_char; use libc::c_int; use libc::c_void; @@ -11,7 +9,7 @@ pub struct isolate { } #[repr(C)] -#[derive(PartialEq)] +#[derive(Clone, PartialEq)] pub struct deno_buf { pub alloc_ptr: *mut u8, pub alloc_len: usize, @@ -30,7 +28,7 @@ extern "C" { pub fn deno_init(); pub fn deno_v8_version() -> *const c_char; pub fn deno_set_v8_flags(argc: *mut c_int, argv: *mut *mut c_char); - pub fn deno_new(cb: DenoRecvCb) -> *const isolate; + pub fn deno_new(snapshot: deno_buf, cb: DenoRecvCb) -> *const isolate; pub fn deno_delete(i: *const isolate); pub fn deno_last_exception(i: *const isolate) -> *const c_char; pub fn deno_check_promise_errors(i: *const isolate); diff --git a/src/main.rs b/src/main.rs index fab7be344..91f566523 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,6 +32,7 @@ mod isolate; mod libdeno; pub mod ops; mod resources; +mod snapshot; mod tokio_util; mod tokio_write; mod version; diff --git a/src/snapshot.cc b/src/snapshot.cc new file mode 100644 index 000000000..b0945d319 --- /dev/null +++ b/src/snapshot.cc @@ -0,0 +1,18 @@ +// Copyright 2018 the Deno authors. All rights reserved. MIT license. + +#include "deno.h" + +extern "C" { + +extern const char snapshot_start asm("snapshot_start"); +extern const char snapshot_end asm("snapshot_end"); +asm(".data\n" + "snapshot_start: .incbin \"gen/snapshot_deno.bin\"\n" + "snapshot_end:\n" + ".globl snapshot_start;\n" + ".globl snapshot_end;"); +extern const deno_buf deno_snapshot = { + nullptr, 0, reinterpret_cast<uint8_t*>(const_cast<char*>(&snapshot_start)), + static_cast<size_t>(&snapshot_end - &snapshot_start)}; + +} diff --git a/src/snapshot.rs b/src/snapshot.rs new file mode 100644 index 000000000..52c8df47d --- /dev/null +++ b/src/snapshot.rs @@ -0,0 +1,5 @@ +// Copyright 2018 the Deno authors. All rights reserved. MIT license. +use libdeno::deno_buf; +extern "C" { + pub static deno_snapshot: deno_buf; +} |