fitzgen added the good first issue label to Issue #10437.
fitzgen opened issue #10437:
We already have code to create default values in order to implement https://docs.rs/wasmtime/latest/wasmtime/struct.Linker.html#method.define_unknown_imports_as_default_values
We have duplicates of that code in the fuzzing utility crate: https://github.com/bytecodealliance/wasmtime/blob/main/crates/fuzzing/src/oracles/dummy.rs
We should just expose those constructors in the public API of the
wasmtimecrate, move the various fuzzing oracles over to these methods, and then delete 95% of thatwasmtime_fuzzing::oracles::dummymodule.I am thinking that we will want to expose these as
pub fn default_value(&self, store: impl AsContextMut) -> Option<T>methods onwasmtime::{ExternType,GlobalType,MemoryType,ValType,...}whereTiswasmtime::Memoryfor thewasmtime::MemoryTypemethod, etc...
shashi1687 commented on issue #10437:
Hi @maintainers :wave:
I’d love to tackle #10437 “Define default-value constructors for various Wasm types in the host API.” I’ve already cloned Wasmtime, run the existing
wasmtime-fuzzingtests, and traced howdummy-linkerusesimport.ty().default_value(&mut *store)to synthesize imports. My plan is to:
- Expose
ExternType::default_valuein the public API by matching on each variant (func, global, memory, table) and returning a defaultExtern.- Add per-type helpers (e.g.
GlobalType::default_value) so users don’t need to manually wrap inExternType.- Write unit tests in
crates/api/tests/default_value.rsfor each type to ensure correct defaults.- Validate via
cargo test,cargo fmt, andcargo clippy --workspace --all-targets.I’m comfortable working in the
wasmtimecrate’s Rust API modules and following the existing style guidelines. Could you please assign this issue to me?
Thanks!
shashi1687 edited a comment on issue #10437:
Hi all,
I’ve traced through
crates/wasmtime/src/runtime/types.rsand can confirm that all fivedefault_valueconstructors are already exposed in the public API:
ExternType::default_value(&self, store) -> Result<Extern>GlobalType::default_value(&self, store) -> Result<RuntimeGlobal>MemoryType::default_value(&self, store) -> Result<RuntimeMemory>TableType::default_value(&self, store) -> Result<RuntimeTable>FuncType::default_value(&self, store) -> Result<Func>That means #10437 is already implemented upstream. My original plan was to:
- Expose these helpers in the public API.
- Add unit tests in
crates/api/tests/default_value.rs.- Validate via
cargo test,cargo fmt, andcargo clippy.Since the code is already present, here are the proposed next steps:
- Test coverage: Add any missing corner-case tests (e.g. tags or other edge types).
- Documentation/examples: Draft a short example in
examples/default_value.rsor update the guide to illustrate these APIs.- Close/Follow-up: If there’s nothing more to add here, please let me know and we can close this issue.
Happy to take on any of the above—just let me know what you’d like!
shashi1687 edited a comment on issue #10437:
Hi all,
I’ve traced through
crates/wasmtime/src/runtime/types.rsand can confirm that all fivedefault_valueconstructors are already exposed in the public API:
ExternType::default_value(&self, store) -> Result<Extern>GlobalType::default_value(&self, store) -> Result<RuntimeGlobal>MemoryType::default_value(&self, store) -> Result<RuntimeMemory>TableType::default_value(&self, store) -> Result<RuntimeTable>FuncType::default_value(&self, store) -> Result<Func>That means #10437 is already implemented upstream. My original plan was to:
- Expose these helpers in the public API.
- Add unit tests in
crates/api/tests/default_value.rs.- Validate via
cargo test,cargo fmt, andcargo clippy.Since the code is already present, here are the proposed next steps:
- Test coverage: Add any missing corner-case tests (e.g. tags or other edge types).
- Documentation/examples: Draft a short example in
examples/default_value.rsor update the guide to illustrate these APIs.- Close/Follow-up: If there’s nothing more to add here, please let me know .
Happy to take on any of the above—just let me know what you’d like!
shashi1687 edited a comment on issue #10437:
Hi all,
I’ve traced through
crates/wasmtime/src/runtime/types.rsand can confirm that all fivedefault_valueconstructors are already exposed in the public API:
ExternType::default_value(&self, store) -> Result<Extern>GlobalType::default_value(&self, store) -> Result<RuntimeGlobal>MemoryType::default_value(&self, store) -> Result<RuntimeMemory>TableType::default_value(&self, store) -> Result<RuntimeTable>FuncType::default_value(&self, store) -> Result<Func>This is my first issue in Wasmtime, and I’d love your suggestions and input on what to do next in this PR:
- Are there any missing corner-case tests you’d like me to add?
- Should I draft an example or update docs to showcase these APIs?
- Is there anything else I can improve or clean up before we close this issue?
Looking forward to your guidance—thanks for your help!
fitzgen commented on issue #10437:
Hi @shashi1687,
It looks like
{Global,Table,Memory}Type::default_valuedo not have any any doc comments. Adding a couple sentences to those docs would be fantastic. Once that is done, I think we can close this issue.
shashi1687 commented on issue #10437:
Hi @fitzgen , thanks for the feedback! I’ve added doc comments to:
GlobalType::default_valueTableType::default_valueMemoryType::default_valueCould you please take another look and let me know if there’s anything else to improve? Thanks! :blush:
shashi1687 deleted a comment on issue #10437:
Hi @fitzgen , thanks for the feedback! I’ve added doc comments to:
GlobalType::default_valueTableType::default_valueMemoryType::default_valueCould you please take another look and let me know if there’s anything else to improve? Thanks! :blush:
shashi1687 commented on issue #10437:
Hi @fitzgen , thanks for the feedback! I’ve added doc comments to:
GlobalType::default_valueTableType::default_valueMemoryType::default_valueCould you please take another look and let me know if there’s anything else to improve? Thanks! :blush:
pchickey closed issue #10437:
We already have code to create default values in order to implement https://docs.rs/wasmtime/latest/wasmtime/struct.Linker.html#method.define_unknown_imports_as_default_values
We have duplicates of that code in the fuzzing utility crate: https://github.com/bytecodealliance/wasmtime/blob/main/crates/fuzzing/src/oracles/dummy.rs
We should just expose those constructors in the public API of the
wasmtimecrate, move the various fuzzing oracles over to these methods, and then delete 95% of thatwasmtime_fuzzing::oracles::dummymodule.I am thinking that we will want to expose these as
pub fn default_value(&self, store: impl AsContextMut) -> Option<T>methods onwasmtime::{ExternType,GlobalType,MemoryType,ValType,...}whereTiswasmtime::Memoryfor thewasmtime::MemoryTypemethod, etc...
Last updated: Dec 13 2025 at 21:03 UTC