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

threads: fuzz shared-everything-threads #1756

Merged
merged 16 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 13 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
8 changes: 8 additions & 0 deletions crates/wasm-encoder/src/core/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ impl RefType {
},
};

/// Create a new abstract reference type.
pub fn new_abstract(ty: AbstractHeapType, nullable: bool, shared: bool) -> Self {
Self {
nullable,
heap_type: HeapType::Abstract { shared, ty },
}
}

/// Set the nullability of this reference type.
pub fn nullable(mut self, nullable: bool) -> Self {
self.nullable = nullable;
Expand Down
31 changes: 28 additions & 3 deletions crates/wasm-smith/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,17 +551,30 @@ define_config! {
/// Defaults to `true`.
pub relaxed_simd_enabled: bool = true,

/// Determines whether the nontrapping-float-to-int-conversions propsal
/// is enabled.
/// Determines whether the non-trapping float-to-int conversions
/// proposal is enabled.
///
/// Defaults to `true`.
pub saturating_float_to_int_enabled: bool = true,

/// Determines whether the sign-extension-ops propsal is enabled.
/// Determines whether the sign-extension-ops proposal is enabled.
///
/// Defaults to `true`.
pub sign_extension_ops_enabled: bool = true,

/// Determines whether the shared-everything-threads proposal is
/// enabled.
///
/// The [shared-everything-threads] proposal, among other things,
/// extends `shared` attributes to all WebAssembly objects; it builds on
/// the [threads] proposal.
///
/// [shared-everything-threads]: https://github.com/WebAssembly/shared-everything-threads
/// [threads]: https://github.com/WebAssembly/threads
///
/// Defaults to `false`.
pub shared_everything_threads_enabled: bool = false,

/// Determines whether the SIMD proposal is enabled for generating
/// instructions.
///
Expand Down Expand Up @@ -754,6 +767,7 @@ impl<'a> Arbitrary<'a> for Config {
memory64_enabled: false,
custom_page_sizes_enabled: false,
wide_arithmetic_enabled: false,
shared_everything_threads_enabled: false,
};
config.sanitize();
Ok(config)
Expand All @@ -779,13 +793,20 @@ impl Config {
if !self.reference_types_enabled {
self.max_tables = self.max_tables.min(1);
self.gc_enabled = false;
self.shared_everything_threads_enabled = false;
}

// If simd is disabled then disable all relaxed simd instructions as
// well.
if !self.simd_enabled {
self.relaxed_simd_enabled = false;
}

// It is impossible to use the shared-everything-threads proposal
// without threads, which it is built on.
if !self.threads_enabled {
self.shared_everything_threads_enabled = false;
}
}

/// Returns the set of features that are necessary for validating against
Expand Down Expand Up @@ -821,6 +842,10 @@ impl Config {
features.set(WasmFeatures::FUNCTION_REFERENCES, self.gc_enabled);
features.set(WasmFeatures::GC, self.gc_enabled);
features.set(WasmFeatures::THREADS, self.threads_enabled);
features.set(
WasmFeatures::SHARED_EVERYTHING_THREADS,
self.shared_everything_threads_enabled,
);
features.set(
WasmFeatures::CUSTOM_PAGE_SIZES,
self.custom_page_sizes_enabled,
Expand Down
Loading