Skip to content

Commit 7b08b93

Browse files
authored
wasm-smith: add support for --exports and --available-imports option (#2160)
* wasm-smith: add support for tags, tables, and memories to the exports field of Config. * wasm-smith: allow GC types in the --available-imports option. * Add the necessary attribute. * Use 'TryFrom' trait instead of 'From' trait for type conversions and refactor the code logic.
1 parent 35e3e49 commit 7b08b93

File tree

5 files changed

+377
-202
lines changed

5 files changed

+377
-202
lines changed

crates/wasm-smith/src/config.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ macro_rules! define_config {
5555
/// module. The implementation (e.g. function bodies, global
5656
/// initializers) of each export in the generated module will be
5757
/// random and unrelated to the implementation in the provided
58-
/// module. Only globals and functions are supported.
58+
/// module.
5959
///
6060
///
6161
/// Defaults to `None` which means arbitrary exports will be
@@ -73,12 +73,13 @@ macro_rules! define_config {
7373
///
7474
/// # Module Limits
7575
///
76-
/// All types, functions, globals, and exports that are needed to
77-
/// provide the required exports will be generated, even if it
78-
/// causes the resulting module to exceed the limits defined in
79-
/// [`Self::max_type_size`], [`Self::max_types`],
80-
/// [`Self::max_funcs`], [`Self::max_globals`], or
81-
/// [`Self::max_exports`].
76+
/// All types, functions, globals, memories, tables, tags, and exports
77+
/// that are needed to provide the required exports will be generated,
78+
/// even if it causes the resulting module to exceed the limits defined
79+
/// in [`Self::max_type_size`], [`Self::max_types`],
80+
/// [`Self::max_funcs`], [`Self::max_globals`],
81+
/// [`Self::max_memories`], [`Self::max_tables`],
82+
/// [`Self::max_tags`], or [`Self::max_exports`].
8283
///
8384
/// # Example
8485
///
@@ -90,6 +91,9 @@ macro_rules! define_config {
9091
/// (module
9192
/// (func (export "foo") (param i32) (result i64) unreachable)
9293
/// (global (export "bar") f32 f32.const 0)
94+
/// (memory (export "baz") 1 10)
95+
/// (table (export "qux") 5 10 (ref null extern))
96+
/// (tag (export "quux") (param f32))
9397
/// )
9498
/// "#));
9599
/// ```
@@ -141,7 +145,7 @@ macro_rules! define_config {
141145
/// module. The implementation (e.g. function bodies, global
142146
/// initializers) of each export in the generated module will be
143147
/// random and unrelated to the implementation in the provided
144-
/// module. Only globals and functions are supported.
148+
/// module.
145149
///
146150
/// Defaults to `None` which means arbitrary exports will be
147151
/// generated.
@@ -158,12 +162,13 @@ macro_rules! define_config {
158162
///
159163
/// # Module Limits
160164
///
161-
/// All types, functions, globals, and exports that are needed to
162-
/// provide the required exports will be generated, even if it
163-
/// causes the resulting module to exceed the limits defined in
164-
/// [`Self::max_type_size`], [`Self::max_types`],
165-
/// [`Self::max_funcs`], [`Self::max_globals`], or
166-
/// [`Self::max_exports`].
165+
/// All types, functions, globals, memories, tables, tags, and exports
166+
/// that are needed to provide the required exports will be generated,
167+
/// even if it causes the resulting module to exceed the limits defined
168+
/// in [`Self::max_type_size`], [`Self::max_types`],
169+
/// [`Self::max_funcs`], [`Self::max_globals`],
170+
/// [`Self::max_memories`], [`Self::max_tables`],
171+
/// [`Self::max_tags`], or [`Self::max_exports`].
167172
///
168173
#[cfg_attr(feature = "clap", clap(long))]
169174
exports: Option<std::path::PathBuf>,

0 commit comments

Comments
 (0)