Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable warnings if cache is disabled #10140

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions crates/wasmtime/src/compile/runtime.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use crate::compile::HashedEngineCompileEnv;
#[cfg(feature = "component-model")]
use crate::component::Component;
use crate::prelude::*;
use crate::runtime::vm::MmapVec;
use crate::{CodeBuilder, CodeMemory, Engine, Module};
use object::write::WritableBuffer;
use std::sync::Arc;
use wasmtime_environ::{FinishedObject, ObjectBuilder, ObjectKind};
use wasmtime_environ::{FinishedObject, ObjectBuilder};

impl<'a> CodeBuilder<'a> {
fn compile_cached<T, S>(
Expand All @@ -29,7 +28,7 @@ impl<'a> CodeBuilder<'a> {
#[cfg(feature = "cache")]
{
let state = (
HashedEngineCompileEnv(self.engine),
crate::compile::HashedEngineCompileEnv(self.engine),
&wasm,
&dwarf_package,
// Don't hash this as it's just its own "pure" function pointer.
Expand Down Expand Up @@ -61,15 +60,21 @@ impl<'a> CodeBuilder<'a> {
// Cache hit, deserialize the provided artifacts
|(engine, wasm, _, _, _), serialized_bytes| {
let kind = if wasmparser::Parser::is_component(&wasm) {
ObjectKind::Component
wasmtime_environ::ObjectKind::Component
} else {
ObjectKind::Module
wasmtime_environ::ObjectKind::Module
};
let code = engine.0.load_code_bytes(&serialized_bytes, kind).ok()?;
Some((code, None))
},
)?;
return Ok((code, info_and_types));

struct NotHashed<T>(T);

impl<T> std::hash::Hash for NotHashed<T> {
fn hash<H: std::hash::Hasher>(&self, _hasher: &mut H) {}
}
}

#[cfg(not(feature = "cache"))]
Expand All @@ -79,12 +84,6 @@ impl<'a> CodeBuilder<'a> {
let code = publish_mmap(self.engine, mmap.0)?;
return Ok((code, info_and_types));
}

struct NotHashed<T>(T);

impl<T> std::hash::Hash for NotHashed<T> {
fn hash<H: std::hash::Hasher>(&self, _hasher: &mut H) {}
}
}

/// Same as [`CodeBuilder::compile_module_serialized`] except that a
Expand Down
1 change: 0 additions & 1 deletion crates/wasmtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@
#![cfg_attr(
any(
not(feature = "async"),
not(feature = "cache"),
not(feature = "gc"),
not(feature = "gc-drc"),
not(feature = "gc-null"),
Expand Down