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

Merge with upstream #49

Merged
merged 2 commits into from
Jan 12, 2024
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
12 changes: 8 additions & 4 deletions crates/wasm-smith/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,14 @@ impl ComponentBuilder {
let ty = match u.int_in_range::<u8>(0..=1)? {
0 => CoreType::Func(crate::core::arbitrary_func_type(
u,
&self.config,
&self.core_valtypes,
if self.config.multi_value_enabled {
None
} else {
Some(1)
},
0,
)?),
1 => CoreType::Module(self.arbitrary_module_type(u, type_fuel)?),
_ => unreachable!(),
Expand Down Expand Up @@ -711,7 +713,7 @@ impl ComponentBuilder {
});
let ty_idx = u32::try_from(types.len()).unwrap();
types.push(realloc_ty.clone());
defs.push(ModuleTypeDef::TypeDef(crate::core::Type::Func(
defs.push(ModuleTypeDef::TypeDef(crate::core::CompositeType::Func(
realloc_ty.clone(),
)));
defs.push(ModuleTypeDef::Export(
Expand All @@ -734,7 +736,7 @@ impl ComponentBuilder {
});
let ty_idx = u32::try_from(types.len()).unwrap();
types.push(free_ty.clone());
defs.push(ModuleTypeDef::TypeDef(crate::core::Type::Func(
defs.push(ModuleTypeDef::TypeDef(crate::core::CompositeType::Func(
free_ty.clone(),
)));
defs.push(ModuleTypeDef::Export(
Expand Down Expand Up @@ -819,15 +821,17 @@ impl ComponentBuilder {
2 => {
let ty = crate::core::arbitrary_func_type(
u,
&self.config,
&self.core_valtypes,
if self.config.multi_value_enabled {
None
} else {
Some(1)
},
0,
)?;
types.push(ty.clone());
defs.push(ModuleTypeDef::TypeDef(crate::core::Type::Func(ty)));
defs.push(ModuleTypeDef::TypeDef(crate::core::CompositeType::Func(ty)));
}

// Alias
Expand Down Expand Up @@ -1900,7 +1904,7 @@ struct ModuleType {

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
enum ModuleTypeDef {
TypeDef(crate::core::Type),
TypeDef(crate::core::CompositeType),
Import(crate::core::Import),
OuterAlias {
count: u32,
Expand Down
5 changes: 4 additions & 1 deletion crates/wasm-smith/src/component/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,15 @@ impl CoreType {
let mut enc_mod_ty = wasm_encoder::ModuleType::new();
for def in &mod_ty.defs {
match def {
ModuleTypeDef::TypeDef(crate::core::Type::Func(func_ty)) => {
ModuleTypeDef::TypeDef(crate::core::CompositeType::Func(func_ty)) => {
enc_mod_ty.ty().function(
func_ty.params.iter().copied(),
func_ty.results.iter().copied(),
);
}
ModuleTypeDef::TypeDef(_) => {
unimplemented!("non-func types in a component's module type")
}
ModuleTypeDef::OuterAlias { count, i, kind } => match kind {
CoreOuterAliasKind::Type(_) => {
enc_mod_ty.alias_outer_core_type(*count, *i);
Expand Down
7 changes: 7 additions & 0 deletions crates/wasm-smith/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ define_config! {
/// This overrides [`Config::min_exports`] and [`Config::max_exports`].
pub export_everything: bool = false,

/// Determines whether the GC proposal is enabled when generating a Wasm
/// module.
///
/// Defaults to `false`.
pub gc_enabled: bool = false,

/// Returns whether we should generate custom sections or not. Defaults
/// to false.
pub generate_custom_sections: bool = false,
Expand Down Expand Up @@ -615,6 +621,7 @@ impl<'a> Arbitrary<'a> for Config {
export_everything: false,
disallow_traps: false,
tail_call_enabled: false,
gc_enabled: false,
generate_custom_sections: false,
typed_continuations_enabled: false,
})
Expand Down
Loading