summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-11-12 17:17:30 -0800
committerGitHub <noreply@github.com>2018-11-12 17:17:30 -0800
commit92e404706b0b1a26cdaf6f8cf81aac148292557f (patch)
tree96a5d48b7dc6cddb6068d57dbffd88abb2e791f9 /src
parent0c740ff85d855177d1619276154f63a36ed31557 (diff)
Use include_bytes! instead of incbin. (#1182)
Diffstat (limited to 'src')
-rw-r--r--src/isolate.rs2
-rw-r--r--src/snapshot.cc18
-rw-r--r--src/snapshot.rs18
3 files changed, 17 insertions, 21 deletions
diff --git a/src/isolate.rs b/src/isolate.rs
index 15a76ba3c..6e8b1864d 100644
--- a/src/isolate.rs
+++ b/src/isolate.rs
@@ -139,7 +139,7 @@ impl Isolate {
});
let shared = empty(); // TODO Use shared for message passing.
let libdeno_isolate = unsafe {
- libdeno::deno_new(snapshot::deno_snapshot.clone(), shared, pre_dispatch)
+ libdeno::deno_new(snapshot::deno_snapshot(), shared, pre_dispatch)
};
// This channel handles sending async messages back to the runtime.
let (tx, rx) = mpsc::channel::<(i32, Buf)>();
diff --git a/src/snapshot.cc b/src/snapshot.cc
deleted file mode 100644
index b0945d319..000000000
--- a/src/snapshot.cc
+++ /dev/null
@@ -1,18 +0,0 @@
-// 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
index 52c8df47d..fcb41f6c8 100644
--- a/src/snapshot.rs
+++ b/src/snapshot.rs
@@ -1,5 +1,19 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
use libdeno::deno_buf;
-extern "C" {
- pub static deno_snapshot: deno_buf;
+use std;
+
+pub fn deno_snapshot() -> deno_buf {
+ let data =
+ include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/snapshot_deno.bin"));
+ let ptr = data.as_ptr();
+ // TODO The transmute is not necessary here. deno_buf specifies mutable
+ // pointers when it doesn't necessarally need mutable. So maybe the deno_buf
+ // type should be broken into a mutable and non-mutable version?
+ let ptr_mut = unsafe { std::mem::transmute::<*const u8, *mut u8>(ptr) };
+ deno_buf {
+ alloc_ptr: std::ptr::null_mut(),
+ alloc_len: 0,
+ data_ptr: ptr_mut,
+ data_len: data.len(),
+ }
}