pub struct BytecodeCache { /* private fields */ }Expand description
On-disk bytecode cache stored under ~/.shape/cache/bytecode/
Implementations§
Source§impl BytecodeCache
impl BytecodeCache
Sourcepub fn new() -> Option<Self>
pub fn new() -> Option<Self>
Create a new bytecode cache, creating the cache directory if needed.
The cache lives at ~/.shape/cache/bytecode/. Returns None if the
home directory cannot be determined or the directory cannot be created.
Sourcepub fn with_dir(cache_dir: PathBuf) -> Result<Self>
pub fn with_dir(cache_dir: PathBuf) -> Result<Self>
Create a cache at a specific directory (for testing).
Sourcepub fn get(&self, source: &str) -> Option<BytecodeProgram>
pub fn get(&self, source: &str) -> Option<BytecodeProgram>
Look up cached bytecode for the given source content.
Returns Some(program) on cache hit, None on miss or deserialization error.
Sourcepub fn put(&self, source: &str, program: &BytecodeProgram) -> Result<()>
pub fn put(&self, source: &str, program: &BytecodeProgram) -> Result<()>
Store compiled bytecode for the given source content.
W17-make-closure note. Programs whose compiler produced any
closure_function_layouts entries (i.e. the source contains at
least one closure literal) are not cached. The ClosureLayout
side-table is currently #[serde(skip)] on BytecodeProgram
and ContentAddressedProgram — a deserialized program would
load with an empty layouts vector, and op_make_closure would
then surface no ClosureLayout registered for function N
(crates/shape-vm/src/executor/control_flow/mod.rs:447). Until
ClosureLayout (+ ConcreteType / FieldInfo / NativeKind /
CaptureKind) grow Serialize/Deserialize derives, the safe
disposition is to skip caching for closure-bearing programs.
Caching for closure-free programs remains in force.
Auto Trait Implementations§
impl Freeze for BytecodeCache
impl RefUnwindSafe for BytecodeCache
impl Send for BytecodeCache
impl Sync for BytecodeCache
impl Unpin for BytecodeCache
impl UnsafeUnpin for BytecodeCache
impl UnwindSafe for BytecodeCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more