summaryrefslogtreecommitdiff
path: root/cli/cache/caches.rs
diff options
context:
space:
mode:
authorIgor Zinkovsky <igor@deno.com>2024-04-17 07:19:55 -0700
committerGitHub <noreply@github.com>2024-04-17 07:19:55 -0700
commitb3d7df55357ea6fc6f5141b64a9638ddb39b0f63 (patch)
tree0ca14140c7e080ed3367a7352bbaf3ed5f7a0f48 /cli/cache/caches.rs
parent9acbf90b06bf79dd6e4cf2428b3566da009bed65 (diff)
perf: v8 code cache (#23081)
This PR enables V8 code cache for ES modules and for `require` scripts through `op_eval_context`. Code cache artifacts are transparently stored and fetched using sqlite db and are passed to V8. `--no-code-cache` can be used to disable. --------- Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/cache/caches.rs')
-rw-r--r--cli/cache/caches.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/cli/cache/caches.rs b/cli/cache/caches.rs
index dc97f02d5..1be14b53b 100644
--- a/cli/cache/caches.rs
+++ b/cli/cache/caches.rs
@@ -8,6 +8,7 @@ use once_cell::sync::OnceCell;
use super::cache_db::CacheDB;
use super::cache_db::CacheDBConfiguration;
use super::check::TYPE_CHECK_CACHE_DB;
+use super::code_cache::CODE_CACHE_DB;
use super::deno_dir::DenoDirProvider;
use super::fast_check::FAST_CHECK_CACHE_DB;
use super::incremental::INCREMENTAL_CACHE_DB;
@@ -22,6 +23,7 @@ pub struct Caches {
fast_check_db: OnceCell<CacheDB>,
node_analysis_db: OnceCell<CacheDB>,
type_checking_cache_db: OnceCell<CacheDB>,
+ code_cache_db: OnceCell<CacheDB>,
}
impl Caches {
@@ -34,6 +36,7 @@ impl Caches {
fast_check_db: Default::default(),
node_analysis_db: Default::default(),
type_checking_cache_db: Default::default(),
+ code_cache_db: Default::default(),
}
}
@@ -124,4 +127,16 @@ impl Caches {
.map(|dir| dir.type_checking_cache_db_file_path()),
)
}
+
+ pub fn code_cache_db(&self) -> CacheDB {
+ Self::make_db(
+ &self.code_cache_db,
+ &CODE_CACHE_DB,
+ self
+ .dir_provider
+ .get_or_create()
+ .ok()
+ .map(|dir| dir.code_cache_db_file_path()),
+ )
+ }
}