1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-27 01:29:14 -05:00
denoland-deno/runtime/code_cache.rs
Igor Zinkovsky b3d7df5535
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>
2024-04-17 07:19:55 -07:00

31 lines
573 B
Rust

// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
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,
specifier: &str,
code_cache_type: CodeCacheType,
source_hash: &str,
) -> Option<Vec<u8>>;
fn set_sync(
&self,
specifier: &str,
code_cache_type: CodeCacheType,
source_hash: &str,
data: &[u8],
);
}