summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2019-01-29 11:41:28 +1000
committerRyan Dahl <ry@tinyclouds.org>2019-01-28 20:41:28 -0500
commitee9c627cc5f92898d104e9359059b57354c9f83c (patch)
tree397428aa26133100e78565755a8b8db169c12131 /src
parentf7c0f4944352f5bd2bb04d6c64e6259357d3827a (diff)
Split out compiler snapshot (#1566)
Speeds up startup time, reduces runtime heap size.
Diffstat (limited to 'src')
-rw-r--r--src/js_errors.rs8
-rw-r--r--src/snapshot.rs12
-rw-r--r--src/workers.rs2
3 files changed, 21 insertions, 1 deletions
diff --git a/src/js_errors.rs b/src/js_errors.rs
index ea94f7c0a..73116d679 100644
--- a/src/js_errors.rs
+++ b/src/js_errors.rs
@@ -355,6 +355,14 @@ fn parse_map_string(
include_str!(concat!(env!("GN_OUT_DIR"), "/gen/bundle/main.js.map"));
SourceMap::from_json(s)
}
+ #[cfg(not(feature = "check-only"))]
+ "gen/bundle/compiler.js" => {
+ let s = include_str!(concat!(
+ env!("GN_OUT_DIR"),
+ "/gen/bundle/compiler.js.map"
+ ));
+ SourceMap::from_json(s)
+ }
_ => match getter.get_source_map(script_name) {
None => None,
Some(raw_source_map) => SourceMap::from_json(&raw_source_map),
diff --git a/src/snapshot.rs b/src/snapshot.rs
index 16a186c29..ac1648e0c 100644
--- a/src/snapshot.rs
+++ b/src/snapshot.rs
@@ -12,3 +12,15 @@ pub fn deno_snapshot() -> deno_buf {
unsafe { deno_buf::from_raw_parts(data.as_ptr(), data.len()) }
}
+
+pub fn compiler_snapshot() -> deno_buf {
+ #[cfg(not(feature = "check-only"))]
+ let data =
+ include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/snapshot_compiler.bin"));
+ // The snapshot blob is not available when the Rust Language Server runs
+ // 'cargo check'.
+ #[cfg(feature = "check-only")]
+ let data = vec![];
+
+ unsafe { deno_buf::from_raw_parts(data.as_ptr(), data.len()) }
+}
diff --git a/src/workers.rs b/src/workers.rs
index 279cc3cc9..5eb75ae13 100644
--- a/src/workers.rs
+++ b/src/workers.rs
@@ -34,7 +34,7 @@ impl Worker {
Some(internal_channels),
));
- let snapshot = snapshot::deno_snapshot();
+ let snapshot = snapshot::compiler_snapshot();
let isolate = Isolate::new(snapshot, state, ops::dispatch);
let worker = Worker { isolate };