summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-11-18 15:09:28 -0500
committerGitHub <noreply@github.com>2024-11-18 20:09:28 +0000
commitdd4570ed85888d9659a2eec98437dbd6de4a5799 (patch)
tree0880f06e3b0f51267ad6e1619941dcc07c5c14c6 /runtime
parent3ba464dbc40dd2d6bd3f7a1912aa8f0fad95058f (diff)
perf(compile): code cache (#26528)
Adds a lazily created code cache to `deno compile` by default. The code cache is created on first run to a single file in the temp directory and is only written once. After it's been written, the code cache becomes read only on subsequent runs. Only the modules loaded during startup are cached (dynamic imports are not code cached). The code cache can be disabled by compiling with `--no-code-cache`.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/code_cache.rs11
1 files changed, 2 insertions, 9 deletions
diff --git a/runtime/code_cache.rs b/runtime/code_cache.rs
index 2a56543a4..b4a7ce188 100644
--- a/runtime/code_cache.rs
+++ b/runtime/code_cache.rs
@@ -2,20 +2,12 @@
use deno_core::ModuleSpecifier;
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum CodeCacheType {
EsModule,
Script,
}
-impl CodeCacheType {
- pub fn as_str(&self) -> &str {
- match self {
- Self::EsModule => "esmodule",
- Self::Script => "script",
- }
- }
-}
-
pub trait CodeCache: Send + Sync {
fn get_sync(
&self,
@@ -23,6 +15,7 @@ pub trait CodeCache: Send + Sync {
code_cache_type: CodeCacheType,
source_hash: u64,
) -> Option<Vec<u8>>;
+
fn set_sync(
&self,
specifier: ModuleSpecifier,