From ee9c627cc5f92898d104e9359059b57354c9f83c Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Tue, 29 Jan 2019 11:41:28 +1000 Subject: Split out compiler snapshot (#1566) Speeds up startup time, reduces runtime heap size. --- src/js_errors.rs | 8 ++++++++ src/snapshot.rs | 12 ++++++++++++ src/workers.rs | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) (limited to 'src') 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 }; -- cgit v1.2.3