A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Add skeleton copying collector (#13093)
Nick Fitzgeraldbc82e7aa57e4
diff --git a/.github/workflows/main.yml b/.github/workflows/main.ymlindex 9d81237a9b..14fa75329c 100644--- a/.github/workflows/main.yml+++ b/.github/workflows/main.yml@@ -360,6 +360,9 @@ jobs:-p wasmtime --no-default-features --features gc-null-p wasmtime --no-default-features --features runtime,gc-null-p wasmtime --no-default-features --features cranelift,gc-null+ -p wasmtime --no-default-features --features gc-copying+ -p wasmtime --no-default-features --features runtime,gc-copying+ -p wasmtime --no-default-features --features cranelift,gc-copying-p wasmtime --no-default-features --features runtime-p wasmtime --no-default-features --features threads-p wasmtime --no-default-features --features runtime,threadsdiff --git a/Cargo.toml b/Cargo.tomlindex adc418fe14..0098943bd7 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -583,6 +583,7 @@ threads = ["wasmtime-cli-flags/threads"]gc = ["wasmtime-cli-flags/gc", "wasmtime/gc"]gc-drc = ["gc", "wasmtime/gc-drc", "wasmtime-cli-flags/gc-drc"]gc-null = ["gc", "wasmtime/gc-null", "wasmtime-cli-flags/gc-null"]+gc-copying = ["gc", "wasmtime/gc-copying", "wasmtime-cli-flags/gc-copying"]pulley = ["wasmtime-cli-flags/pulley"]stack-switching = ["wasmtime/stack-switching", "wasmtime-cli-flags/stack-switching"]debug = ["wasmtime-cli-flags/debug", "wasmtime/debug", "component-model"]diff --git a/crates/c-api/Cargo.toml b/crates/c-api/Cargo.tomlindex 34f22dd67e..221537f662 100644--- a/crates/c-api/Cargo.toml+++ b/crates/c-api/Cargo.toml@@ -58,6 +58,7 @@ threads = ["wasmtime/threads"]gc = ["wasmtime/gc"]gc-drc = ["wasmtime/gc-drc"]gc-null = ["wasmtime/gc-null"]+gc-copying = ["wasmtime/gc-copying"]cranelift = ['wasmtime/cranelift']winch = ['wasmtime/winch']debug-builtins = ['wasmtime/debug-builtins']diff --git a/crates/c-api/artifact/Cargo.toml b/crates/c-api/artifact/Cargo.tomlindex f1b3e82b4f..026f0816ac 100644--- a/crates/c-api/artifact/Cargo.toml+++ b/crates/c-api/artifact/Cargo.toml@@ -64,6 +64,7 @@ threads = ["wasmtime-c-api/threads"]gc = ["wasmtime-c-api/gc"]gc-drc = ["wasmtime-c-api/gc-drc"]gc-null = ["wasmtime-c-api/gc-null"]+gc-copying = ["wasmtime-c-api/gc-copying"]cranelift = ["wasmtime-c-api/cranelift"]winch = ["wasmtime-c-api/winch"]debug-builtins = ["wasmtime-c-api/debug-builtins"]diff --git a/crates/cli-flags/Cargo.toml b/crates/cli-flags/Cargo.tomlindex 4873875fea..6a22e005f1 100644--- a/crates/cli-flags/Cargo.toml+++ b/crates/cli-flags/Cargo.toml@@ -35,6 +35,7 @@ coredump = ["wasmtime/coredump"]gc = ["wasmtime/gc"]gc-drc = ["gc", "wasmtime/gc-drc"]gc-null = ["gc", "wasmtime/gc-null"]+gc-copying = ["gc", "wasmtime/gc-copying"]threads = ["wasmtime/threads"]memory-protection-keys = ["wasmtime/memory-protection-keys"]pulley = ["wasmtime/pulley"]diff --git a/crates/cli-flags/src/lib.rs b/crates/cli-flags/src/lib.rsindex 45b0e8f478..c14478cf11 100644--- a/crates/cli-flags/src/lib.rs+++ b/crates/cli-flags/src/lib.rs@@ -234,13 +234,15 @@ wasmtime_option_group! {#[serde(default)]#[serde(deserialize_with = "crate::opt::cli_parse_wrapper")]pub compiler: Option<wasmtime::Strategy>,- /// Which garbage collector to use: `drc` or `null`.+ /// Which garbage collector to use: `drc`, `null`, or `copying`.////// `drc` is the deferred reference-counting collector.////// `null` is the null garbage collector, which does not collect any/// garbage.///+ /// `copying` is the copying garbage collector (not yet implemented).+ ////// Note that not all builds of Wasmtime will have support for garbage/// collection included.#[serde(default)]@@ -1325,6 +1327,7 @@ mod tests {Some(wasmtime::Collector::DeferredReferenceCounting),),("\"null\"", Some(wasmtime::Collector::Null)),+ ("\"copying\"", Some(wasmtime::Collector::Copying)),("\"hello\"", None), // should fail("5", None), // should fail("true", None), // should faildiff --git a/crates/cli-flags/src/opt.rs b/crates/cli-flags/src/opt.rsindex 9377278675..f1469bb45a 100644--- a/crates/cli-flags/src/opt.rs+++ b/crates/cli-flags/src/opt.rs@@ -548,12 +548,15 @@ impl WasmtimeOptionValue for wasmtime::Strategy {}impl WasmtimeOptionValue for wasmtime::Collector {- const VAL_HELP: &'static str = "=drc|null";+ const VAL_HELP: &'static str = "=drc|null|copying";fn parse(val: Option<&str>) -> Result<Self> {match String::parse(val)?.as_str() {"drc" => Ok(wasmtime::Collector::DeferredReferenceCounting),"null" => Ok(wasmtime::Collector::Null),- other => bail!("unknown collector `{other}` only `drc` and `null` accepted",),+ "copying" => Ok(wasmtime::Collector::Copying),+ other => {+ bail!("unknown collector `{other}` only `drc`, `null`, and `copying` accepted",)+ }}}@@ -561,6 +564,7 @@ impl WasmtimeOptionValue for wasmtime::Collector {match *self {wasmtime::Collector::DeferredReferenceCounting => f.write_str("drc"),wasmtime::Collector::Null => f.write_str("null"),+ wasmtime::Collector::Copying => f.write_str("copying"),_ => unreachable!(),}}diff --git a/crates/cranelift/Cargo.toml b/crates/cranelift/Cargo.tomlindex f8f54cf7fa..0aadcedf23 100644--- a/crates/cranelift/Cargo.toml+++ b/crates/cranelift/Cargo.toml@@ -46,5 +46,6 @@ wmemcheck = ["wasmtime-environ/wmemcheck"]gc = ["wasmtime-environ/gc"]gc-drc = ["gc", "wasmtime-environ/gc-drc"]gc-null = ["gc", "wasmtime-environ/gc-null"]+gc-copying = ["gc", "wasmtime-environ/gc-copying"]stack-switching = []threads = ["wasmtime-environ/threads"]diff --git a/crates/cranelift/src/func_environ/gc.rs b/crates/cranelift/src/func_environ/gc.rsindex 87cc59a212..c3c6c2b0b0 100644--- a/crates/cranelift/src/func_environ/gc.rs+++ b/crates/cranelift/src/func_environ/gc.rs@@ -26,7 +26,10 @@ pub use imp::*;/// How to initialize a newly-allocated array's elements.#[derive(Clone, Copy)]-#[cfg_attr(not(feature = "gc"), expect(dead_code))]+#[cfg_attr(+ not(any(feature = "gc-drc", feature = "gc-null")),+ allow(dead_code, reason = "easier to define")+)]pub enum ArrayInit<'a> {/// Initialize the array's elements with the given values.Elems(&'a [ir::Value]),diff --git a/crates/cranelift/src/func_environ/gc/enabled.rs b/crates/cranelift/src/func_environ/gc/enabled.rsindex d2d42715a3..bd6013d3fb 100644--- a/crates/cranelift/src/func_environ/gc/enabled.rs+++ b/crates/cranelift/src/func_environ/gc/enabled.rs@@ -24,6 +24,9 @@ mod drc;#[cfg(feature = "gc-null")]mod null;+#[cfg(feature = "gc-copying")]+mod copying;+/// Get the default GC compiler.pub fn gc_compiler(func_env: &mut FuncEnvironment<'_>) -> WasmResult<Box<dyn GcCompiler>> {// If this function requires a GC compiler, that is not too bad of an@@ -47,11 +50,19 @@ pub fn gc_compiler(func_env: &mut FuncEnvironment<'_>) -> WasmResult<Box<dyn GcCwas disabled at compile time",)),- #[cfg(any(feature = "gc-drc", feature = "gc-null"))]+ #[cfg(feature = "gc-copying")]+ Some(Collector::Copying) => Ok(Box::new(copying::CopyingCompiler::default())),+ #[cfg(not(feature = "gc-copying"))]+ Some(Collector::Copying) => Err(wasm_unsupported!(+ "the copying collector is unavailable because the `gc-copying` feature \+ was disabled at compile time",+ )),++ #[cfg(any(feature = "gc-drc", feature = "gc-null", feature = "gc-copying"))]None => Err(wasm_unsupported!("support for GC types disabled at configuration time")),- #[cfg(not(any(feature = "gc-drc", feature = "gc-null")))]+ #[cfg(not(any(feature = "gc-drc", feature = "gc-null", feature = "gc-copying")))]None => Err(wasm_unsupported!("support for GC types disabled because no collector implementation \was selected at compile time; enable one of the `gc-drc` or \diff --git a/crates/cranelift/src/func_environ/gc/enabled/copying.rs b/crates/cranelift/src/func_environ/gc/enabled/copying.rsnew file mode 100644index 0000000000..0faeb07495--- /dev/null+++ b/crates/cranelift/src/func_environ/gc/enabled/copying.rs@@ -0,0 +1,89 @@+//! Compiler for the copying collector.+//!+//! This is a skeleton implementation that is not yet functional. All methods+//! return `WasmError::Unsupported` errors.++use super::*;+use crate::func_environ::FuncEnvironment;+use cranelift_codegen::ir;+use cranelift_frontend::FunctionBuilder;+use wasmtime_environ::{+ GcTypeLayouts, TypeIndex, WasmRefType, WasmResult, copying::CopyingTypeLayouts,+ wasm_unsupported,+};++#[derive(Default)]+pub struct CopyingCompiler {+ layouts: CopyingTypeLayouts,+}++impl GcCompiler for CopyingCompiler {+ fn layouts(&self) -> &dyn GcTypeLayouts {+ &self.layouts+ }++ fn alloc_array(+ &mut self,+ _func_env: &mut FuncEnvironment<'_>,+ _builder: &mut FunctionBuilder<'_>,+ _array_type_index: TypeIndex,+ _init: super::ArrayInit<'_>,+ ) -> WasmResult<ir::Value> {+ Err(wasm_unsupported!(+ "copying collector is not yet implemented"+ ))+ }++ fn alloc_struct(+ &mut self,+ _func_env: &mut FuncEnvironment<'_>,+ _builder: &mut FunctionBuilder<'_>,+ _struct_type_index: TypeIndex,+ _field_vals: &[ir::Value],+ ) -> WasmResult<ir::Value> {+ Err(wasm_unsupported!(+ "copying collector is not yet implemented"+ ))+ }++ fn alloc_exn(+ &mut self,+ _func_env: &mut FuncEnvironment<'_>,+ _builder: &mut FunctionBuilder<'_>,+ _tag_index: TagIndex,+ _field_vals: &[ir::Value],+ _instance_id: ir::Value,+ _tag: ir::Value,+ ) -> WasmResult<ir::Value> {+ Err(wasm_unsupported!(+ "copying collector is not yet implemented"+ ))+ }++ fn translate_read_gc_reference(+ &mut self,+ _func_env: &mut FuncEnvironment<'_>,+ _builder: &mut FunctionBuilder,+ _ty: WasmRefType,+ _src: ir::Value,+ _flags: ir::MemFlags,+ ) -> WasmResult<ir::Value> {+ Err(wasm_unsupported!(+ "copying collector is not yet implemented"+ ))+ }++ fn translate_write_gc_reference(+ &mut self,+ _func_env: &mut FuncEnvironment<'_>,+ _builder: &mut FunctionBuilder,+ _ty: WasmRefType,+ _dst: ir::Value,+ _new_val: ir::Value,+ _flags: ir::MemFlags,+ ) -> WasmResult<()> {+ Err(wasm_unsupported!(+ "copying collector is not yet implemented"+ ))+ }+}diff --git a/crates/environ/Cargo.toml b/crates/environ/Cargo.tomlindex d2267ff8bb..d3196c3d42 100644--- a/crates/environ/Cargo.toml+++ b/crates/environ/Cargo.toml@@ -74,6 +74,7 @@ demangle = ['dep:rustc-demangle', 'dep:cpp_demangle']gc = []gc-drc = ["gc"]gc-null = ["gc"]+gc-copying = ["gc"]compile = ['gimli/write','object/write_core',diff --git a/crates/environ/src/gc.rs b/crates/environ/src/gc.rsindex 5de8ba4a24..3a11d9721a 100644--- a/crates/environ/src/gc.rs+++ b/crates/environ/src/gc.rs@@ -15,6 +15,9 @@ pub mod drc;#[cfg(feature = "gc-null")]pub mod null;+#[cfg(feature = "gc-copying")]+pub mod copying;+use crate::{WasmArrayType, WasmCompositeInnerType, WasmCompositeType, WasmExnType, WasmStorageType,WasmStructType, WasmValType, error::OutOfMemory, prelude::*,@@ -67,7 +70,7 @@ pub fn byte_size_of_wasm_ty_in_gc_heap(ty: &WasmStorageType) -> u32 {/// Align `offset` up to `bytes`, updating `max_align` if `align` is the/// new maximum alignment, and returning the aligned offset.-#[cfg(any(feature = "gc-drc", feature = "gc-null"))]+#[cfg(any(feature = "gc-drc", feature = "gc-null", feature = "gc-copying"))]fn align_up(offset: &mut u32, max_align: &mut u32, align: u32) -> u32 {debug_assert!(max_align.is_power_of_two());debug_assert!(align.is_power_of_two());@@ -79,7 +82,7 @@ fn align_up(offset: &mut u32, max_align: &mut u32, align: u32) -> u32 {/// Define a new field of size and alignment `bytes`, updating the object's/// total `size` and `align` as necessary. The offset of the new field is/// returned.-#[cfg(any(feature = "gc-drc", feature = "gc-null"))]+#[cfg(any(feature = "gc-drc", feature = "gc-null", feature = "gc-copying"))]fn field(size: &mut u32, align: &mut u32, bytes: u32) -> u32 {let offset = align_up(size, align, bytes);*size += bytes;@@ -88,7 +91,7 @@ fn field(size: &mut u32, align: &mut u32, bytes: u32) -> u32 {/// Common code to define a GC array's layout, given the size and alignment of/// the collector's GC header and its expected offset of the array length field.-#[cfg(any(feature = "gc-drc", feature = "gc-null"))]+#[cfg(any(feature = "gc-drc", feature = "gc-null", feature = "gc-copying"))]fn common_array_layout(ty: &WasmArrayType,header_size: u32,@@ -131,7 +134,7 @@ fn common_array_layout(/// Shared layout code for structs and exception objects, which are/// identical except for the tag field (present in/// exceptions). Returns `(size, align, fields)`.-#[cfg(any(feature = "gc-null", feature = "gc-drc"))]+#[cfg(any(feature = "gc-null", feature = "gc-drc", feature = "gc-copying"))]fn common_struct_or_exn_layout(fields: &[crate::WasmFieldType],header_size: u32,@@ -172,7 +175,7 @@ fn common_struct_or_exn_layout(/// Common code to define a GC struct's layout, given the size and alignment of/// the collector's GC header and its expected offset of the array length field.-#[cfg(any(feature = "gc-null", feature = "gc-drc"))]+#[cfg(any(feature = "gc-null", feature = "gc-drc", feature = "gc-copying"))]fn common_struct_layout(ty: &WasmStructType,header_size: u32,@@ -194,7 +197,7 @@ fn common_struct_layout(/// Common code to define a GC exception object's layout, given the/// size and alignment of the collector's GC header and its expected/// offset of the array length field.-#[cfg(any(feature = "gc-null", feature = "gc-drc"))]+#[cfg(any(feature = "gc-null", feature = "gc-drc", feature = "gc-copying"))]fn common_exn_layout(ty: &WasmExnType, header_size: u32, header_align: u32) -> GcStructLayout {assert!(header_size >= crate::VM_GC_HEADER_SIZE);assert!(header_align >= crate::VM_GC_HEADER_ALIGN);diff --git a/crates/environ/src/gc/copying.rs b/crates/environ/src/gc/copying.rsnew file mode 100644index 0000000000..39e7a27e5e--- /dev/null+++ b/crates/environ/src/gc/copying.rs@@ -0,0 +1,48 @@+//! Layout of Wasm GC objects in the copying garbage collector.++use super::*;++/// The size of the `VMCopyingHeader` header for GC objects.+pub const HEADER_SIZE: u32 = 8;++/// The align of the `VMCopyingHeader` header for GC objects.+pub const HEADER_ALIGN: u32 = 8;++/// The offset of the length field in a `VMCopyingArrayHeader`.+pub const ARRAY_LENGTH_OFFSET: u32 = HEADER_SIZE;++/// The offset of the tag-instance-index field in an exception header.+pub const EXCEPTION_TAG_INSTANCE_OFFSET: u32 = HEADER_SIZE;++/// The offset of the tag-defined-index field in an exception header.+pub const EXCEPTION_TAG_DEFINED_OFFSET: u32 = HEADER_SIZE + 4;++/// The layout of Wasm GC objects in the copying collector.+#[derive(Default)]+pub struct CopyingTypeLayouts;++impl GcTypeLayouts for CopyingTypeLayouts {+ fn array_length_field_offset(&self) -> u32 {+ ARRAY_LENGTH_OFFSET+ }++ fn exception_tag_instance_offset(&self) -> u32 {+ EXCEPTION_TAG_INSTANCE_OFFSET+ }++ fn exception_tag_defined_offset(&self) -> u32 {+ EXCEPTION_TAG_DEFINED_OFFSET+ }++ fn array_layout(&self, ty: &WasmArrayType) -> GcArrayLayout {+ common_array_layout(ty, HEADER_SIZE, HEADER_ALIGN, ARRAY_LENGTH_OFFSET)+ }++ fn struct_layout(&self, ty: &WasmStructType) -> GcStructLayout {+ common_struct_layout(ty, HEADER_SIZE, HEADER_ALIGN)+ }++ fn exn_layout(&self, ty: &WasmExnType) -> GcStructLayout {+ common_exn_layout(ty, HEADER_SIZE, HEADER_ALIGN)+ }+}diff --git a/crates/environ/src/tunables.rs b/crates/environ/src/tunables.rsindex 354021e0dc..e235b0cf9b 100644--- a/crates/environ/src/tunables.rs+++ b/crates/environ/src/tunables.rs@@ -412,6 +412,8 @@ pub enum Collector {DeferredReferenceCounting,/// The null collector.Null,+ /// The copying collector.+ Copying,}impl fmt::Display for Collector {@@ -419,6 +421,7 @@ impl fmt::Display for Collector {match self {Collector::DeferredReferenceCounting => write!(f, "deferred reference-counting"),Collector::Null => write!(f, "null"),+ Collector::Copying => write!(f, "copying"),}}}diff --git a/crates/test-util/src/wasmtime_wast.rs b/crates/test-util/src/wasmtime_wast.rsindex c64b193224..bfa2ca5597 100644--- a/crates/test-util/src/wasmtime_wast.rs+++ b/crates/test-util/src/wasmtime_wast.rs@@ -19,6 +19,7 @@ pub fn apply_wast_config(config: &mut Config, wast_config: &wast::WastConfig) {Collector::Auto => wasmtime::Collector::Auto,Collector::Null => wasmtime::Collector::Null,Collector::DeferredReferenceCounting => wasmtime::Collector::DeferredReferenceCounting,+ Collector::Copying => wasmtime::Collector::Copying,});}diff --git a/crates/test-util/src/wast.rs b/crates/test-util/src/wast.rsindex e7116d3880..82a2dbe9b5 100644--- a/crates/test-util/src/wast.rs+++ b/crates/test-util/src/wast.rs@@ -445,6 +445,7 @@ pub enum Collector {Auto,Null,DeferredReferenceCounting,+ Copying,}impl WastTest {diff --git a/crates/wasmtime/Cargo.toml b/crates/wasmtime/Cargo.tomlindex b1b2d45e23..7c9c2e1e6e 100644--- a/crates/wasmtime/Cargo.toml+++ b/crates/wasmtime/Cargo.toml@@ -289,7 +289,7 @@ runtime = [# load and run Wasm that uses those proposals.## You can additionally configure which GC implementations are enabled via the-# `gc-drc` and `gc-null` features.+# `gc-drc`, `gc-null`, and `gc-copying` features.gc = ["wasmtime-environ/gc","wasmtime-cranelift?/gc",@@ -312,6 +312,14 @@ gc-null = ["wasmtime-winch?/gc-null",]+# Enable the copying garbage collector.+gc-copying = [+ "gc",+ "wasmtime-environ/gc-copying",+ "wasmtime-cranelift?/gc-copying",+ "wasmtime-winch?/gc-copying",+]+# Enable runtime support for the WebAssembly threads proposal.threads = ["wasmtime-cranelift?/threads",diff --git a/crates/wasmtime/src/config.rs b/crates/wasmtime/src/config.rsindex a51bb7f2a7..9459dbda90 100644--- a/crates/wasmtime/src/config.rs+++ b/crates/wasmtime/src/config.rs@@ -2592,6 +2592,7 @@ impl Config {Some(match self.collector.try_not_auto()? {Collector::DeferredReferenceCounting => EnvCollector::DeferredReferenceCounting,Collector::Null => EnvCollector::Null,+ Collector::Copying => EnvCollector::Copying,Collector::Auto => unreachable!(),})}@@ -2728,7 +2729,7 @@ impl Config {#[cfg(feature = "gc")]#[cfg_attr(- not(any(feature = "gc-null", feature = "gc-drc")),+ not(any(feature = "gc-null", feature = "gc-drc", feature = "gc-copying")),expect(unreachable_code, reason = "definitions known to be dummy"))]{@@ -2747,6 +2748,13 @@ impl Config {#[cfg(not(feature = "gc-null"))]Collector::Null => unreachable!(),+ #[cfg(feature = "gc-copying")]+ Collector::Copying => {+ try_new::<Arc<_>>(crate::runtime::vm::CopyingCollector::default())? as _+ }+ #[cfg(not(feature = "gc-copying"))]+ Collector::Copying => unreachable!(),+Collector::Auto => unreachable!(),}))}@@ -3325,10 +3333,11 @@ impl Strategy {/// The properties of Wasmtime's available collectors are summarized in the/// following table:///-/// | Collector | Collects Garbage[^1] | Latency[^2] | Throughput[^3] | Allocation Speed[^4] | Heap Utilization[^5] |-/// |-----------------------------|----------------------|-------------|----------------|----------------------|----------------------|-/// | `DeferredReferenceCounting` | Yes, but not cycles | π | π | π | π |-/// | `Null` | No | π | π | π | π |+/// | Collector | Collects Garbage[^1] | Latency[^2] | Throughput[^3] | Allocation Speed[^4] | Heap Utilization[^5] |+/// |-----------------------------|-----------------------|-------------|----------------|----------------------|----------------------|+/// | `DeferredReferenceCounting` | Yes, but not cycles | π | π | π | π |+/// | `Null` | No | π | π | π | π |+/// | `Copying`[^copying] | Yes, including cycles | π | π | π | π |////// [^1]: Whether or not the collector is capable of collecting garbage and cyclic garbage.///@@ -3348,6 +3357,9 @@ impl Strategy {/// require? Less space taken up by metadata means more space for/// additional objects. Reference counts are larger than mark bits and/// free lists are larger than bump pointers, for example.+///+/// [^copying]: The copying collector is still under construction and is not yet+/// functional.#[non_exhaustive]#[derive(PartialEq, Eq, Clone, Debug, Copy)]pub enum Collector {@@ -3393,6 +3405,20 @@ pub enum Collector {/// collectors, as this collector imposes as close to zero throughput and/// latency overhead as possible.Null,++ /// The copying collector.+ ///+ /// A tracing collector that splits the GC heap in half, bump-allocates+ /// objects in one half until it fills up, and then does a GC and copies+ /// live objects into the other half, and repeats the process. It has fast+ /// allocation, collects cyclic garbage, and good collection throughput,+ /// however it suffers from poor latency due to its stop-the-world+ /// collections and poor heap utilization due to only using half the GC+ /// heap's full capacity at any given time.+ ///+ /// Note that this collector is still under construction and is not yet+ /// functional.+ Copying,}impl Default for Collector {@@ -3437,12 +3463,20 @@ impl Collector {the `gc-null` feature was not enabled at compile time",),+ #[cfg(feature = "gc-copying")]+ Some(c @ Collector::Copying) => Ok(c),+ #[cfg(not(feature = "gc-copying"))]+ Some(Collector::Copying) => bail!(+ "cannot create an engine using the copying collector because \+ the `gc-copying` feature was not enabled at compile time",+ ),+Some(Collector::Auto) => unreachable!(),None => bail!("cannot create an engine with GC support when none of the \collectors are available; enable one of the following \- features: `gc-drc`, `gc-null`",+ features: `gc-drc`, `gc-null`, `gc-copying`",),}}diff --git a/crates/wasmtime/src/runtime/vm/gc/enabled.rs b/crates/wasmtime/src/runtime/vm/gc/enabled.rsindex f4542ed25a..d4eac7a621 100644--- a/crates/wasmtime/src/runtime/vm/gc/enabled.rs+++ b/crates/wasmtime/src/runtime/vm/gc/enabled.rs@@ -24,6 +24,11 @@ mod null;#[cfg(feature = "gc-null")]pub use null::*;+#[cfg(feature = "gc-copying")]+mod copying;+#[cfg(feature = "gc-copying")]+pub use copying::*;+// Explicit methods to clearly indicate that truncation is desired when used.#[expect(clippy::cast_possible_truncation,diff --git a/crates/wasmtime/src/runtime/vm/gc/enabled/copying.rs b/crates/wasmtime/src/runtime/vm/gc/enabled/copying.rsnew file mode 100644index 0000000000..69fefea26f--- /dev/null+++ b/crates/wasmtime/src/runtime/vm/gc/enabled/copying.rs@@ -0,0 +1,23 @@+//! The copying collector.+//!+//! This is a skeleton implementation that is not yet functional. All methods+//! bail with "not yet implemented" errors.++use crate::{Engine, prelude::*, vm::GcRuntime};+use wasmtime_environ::{GcTypeLayouts, copying::CopyingTypeLayouts};++/// The copying collector.+#[derive(Default)]+pub struct CopyingCollector {+ layouts: CopyingTypeLayouts,+}++unsafe impl GcRuntime for CopyingCollector {+ fn layouts(&self) -> &dyn GcTypeLayouts {+ &self.layouts+ }++ fn new_gc_heap(&self, _: &Engine) -> Result<Box<dyn crate::vm::GcHeap>> {+ bail!("copying collector is not yet implemented")+ }+}diff --git a/crates/winch/Cargo.toml b/crates/winch/Cargo.tomlindex 3febbbbb8a..80f6992168 100644--- a/crates/winch/Cargo.toml+++ b/crates/winch/Cargo.toml@@ -31,6 +31,7 @@ all-arch = ["winch-codegen/all-arch"]gc = ['winch-codegen/gc']gc-drc = ['winch-codegen/gc-drc']gc-null = ['winch-codegen/gc-null']+gc-copying = ['winch-codegen/gc-copying']stack-switching = ['winch-codegen/stack-switching']threads = ['winch-codegen/threads']wmemcheck = ['winch-codegen/wmemcheck']diff --git a/winch/codegen/Cargo.toml b/winch/codegen/Cargo.tomlindex d7672fd724..e9d2dba097 100644--- a/winch/codegen/Cargo.toml+++ b/winch/codegen/Cargo.toml@@ -38,6 +38,7 @@ all-arch = [gc = ['wasmtime-environ/gc']gc-drc = ['wasmtime-environ/gc-drc']gc-null = ['wasmtime-environ/gc-null']+gc-copying = ['wasmtime-environ/gc-copying']stack-switching = ['wasmtime-environ/stack-switching']threads = ['wasmtime-environ/threads']wmemcheck = ['wasmtime-environ/wmemcheck']