Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Move `StringPool` to `wasmtime-environ` (#12562)

Nick Fitzgeraldc12e1698d0ad
diff --git a/crates/core/src/alloc/try_clone.rs b/crates/core/src/alloc/try_clone.rs
index 09d03975bb..c59b62380b 100644
--- a/crates/core/src/alloc/try_clone.rs
+++ b/crates/core/src/alloc/try_clone.rs
@@ -104,7 +104,6 @@ impl_try_clone_via_clone! {
std::hash::RandomState
}
-#[cfg(not(feature = "std"))]
impl_try_clone_via_clone! {
hashbrown::DefaultHashBuilder
}
diff --git a/crates/environ/src/lib.rs b/crates/environ/src/lib.rs
index 29806dd0b3..f7bd814eae 100644
--- a/crates/environ/src/lib.rs
+++ b/crates/environ/src/lib.rs
@@ -36,6 +36,7 @@ mod ref_bits;
mod scopevec;
mod stack_map;
mod stack_switching;
+mod string_pool;
mod trap_encoding;
mod tunables;
mod types;
@@ -57,6 +58,7 @@ pub use crate::ref_bits::*;
pub use crate::scopevec::ScopeVec;
pub use crate::stack_map::*;
pub use crate::stack_switching::*;
+pub use crate::string_pool::{Atom, StringPool};
pub use crate::trap_encoding::*;
pub use crate::tunables::*;
pub use crate::types::*;
diff --git a/crates/wasmtime/src/runtime/string_pool.rs b/crates/environ/src/string_pool.rs
similarity index 98%
rename from crates/wasmtime/src/runtime/string_pool.rs
rename to crates/environ/src/string_pool.rs
index 3c01d42e62..e4ecda55fe 100644
--- a/crates/wasmtime/src/runtime/string_pool.rs
+++ b/crates/environ/src/string_pool.rs
@@ -1,9 +1,12 @@
//! Simple string interning.
-use crate::{error::OutOfMemory, prelude::*};
+use crate::{
+ collections::{HashMap, String, Vec},
+ error::OutOfMemory,
+ prelude::*,
+};
use core::{fmt, mem, num::NonZeroU32};
use wasmtime_core::alloc::TryClone;
-use wasmtime_environ::collections::{HashMap, String, Vec};
/// A pool of interned strings.
///
diff --git a/crates/wasmtime/src/runtime.rs b/crates/wasmtime/src/runtime.rs
index 471e0daf46..e9417931a2 100644
--- a/crates/wasmtime/src/runtime.rs
+++ b/crates/wasmtime/src/runtime.rs
@@ -49,7 +49,6 @@ pub(crate) mod module;
pub(crate) mod native_debug;
pub(crate) mod resources;
pub(crate) mod store;
-pub(crate) mod string_pool;
pub(crate) mod trampoline;
pub(crate) mod trap;
pub(crate) mod type_registry;
diff --git a/crates/wasmtime/src/runtime/linker.rs b/crates/wasmtime/src/runtime/linker.rs
index 5ba1859e51..0c4fb71f3a 100644
--- a/crates/wasmtime/src/runtime/linker.rs
+++ b/crates/wasmtime/src/runtime/linker.rs
@@ -1,7 +1,6 @@
use crate::error::OutOfMemory;
use crate::func::HostFunc;
use crate::instance::InstancePre;
-use crate::runtime::string_pool::{Atom, StringPool};
use crate::store::StoreOpaque;
use crate::{
AsContext, AsContextMut, Caller, Engine, Extern, ExternType, Func, FuncType, ImportType,
@@ -15,7 +14,7 @@ use core::marker;
use core::mem::MaybeUninit;
use log::warn;
use wasmtime_environ::{
- PanicOnOom as _,
+ Atom, PanicOnOom as _, StringPool,
collections::{HashMap, TryClone},
};