summaryrefslogtreecommitdiff
path: root/runtime/js.rs
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/js.rs')
-rw-r--r--runtime/js.rs40
1 files changed, 12 insertions, 28 deletions
diff --git a/runtime/js.rs b/runtime/js.rs
index 54a08d9b4..3ad241670 100644
--- a/runtime/js.rs
+++ b/runtime/js.rs
@@ -2,17 +2,18 @@
use deno_core::Snapshot;
use log::debug;
use once_cell::sync::Lazy;
+use std::path::PathBuf;
-pub static CLI_SNAPSHOT: Lazy<Box<[u8]>> = Lazy::new(
+pub static RUNTIME_SNAPSHOT: Lazy<Box<[u8]>> = Lazy::new(
#[allow(clippy::uninit_vec)]
#[cold]
#[inline(never)]
|| {
- static COMPRESSED_CLI_SNAPSHOT: &[u8] =
- include_bytes!(concat!(env!("OUT_DIR"), "/CLI_SNAPSHOT.bin"));
+ static COMPRESSED_RUNTIME_SNAPSHOT: &[u8] =
+ include_bytes!(concat!(env!("OUT_DIR"), "/RUNTIME_SNAPSHOT.bin"));
let size =
- u32::from_le_bytes(COMPRESSED_CLI_SNAPSHOT[0..4].try_into().unwrap())
+ u32::from_le_bytes(COMPRESSED_RUNTIME_SNAPSHOT[0..4].try_into().unwrap())
as usize;
let mut vec = Vec::with_capacity(size);
@@ -22,7 +23,8 @@ pub static CLI_SNAPSHOT: Lazy<Box<[u8]>> = Lazy::new(
vec.set_len(size);
}
- lzzzz::lz4::decompress(&COMPRESSED_CLI_SNAPSHOT[4..], &mut vec).unwrap();
+ lzzzz::lz4::decompress(&COMPRESSED_RUNTIME_SNAPSHOT[4..], &mut vec)
+ .unwrap();
vec.into_boxed_slice()
},
@@ -30,29 +32,11 @@ pub static CLI_SNAPSHOT: Lazy<Box<[u8]>> = Lazy::new(
pub fn deno_isolate_init() -> Snapshot {
debug!("Deno isolate init with snapshots.");
- Snapshot::Static(&CLI_SNAPSHOT)
+ Snapshot::Static(&RUNTIME_SNAPSHOT)
}
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn cli_snapshot() {
- let mut js_runtime = deno_core::JsRuntime::new(deno_core::RuntimeOptions {
- startup_snapshot: Some(deno_isolate_init()),
- ..Default::default()
- });
- js_runtime
- .execute_script(
- "<anon>",
- r#"
- if (!(bootstrap.mainRuntime && bootstrap.workerRuntime)) {
- throw Error("bad");
- }
- console.log("we have console.log!!!");
- "#,
- )
- .unwrap();
- }
+pub fn get_99_main() -> PathBuf {
+ let manifest = env!("CARGO_MANIFEST_DIR");
+ let path = PathBuf::from(manifest);
+ path.join("js").join("99_main.js")
}