Skip to content

Commit

Permalink
Fix table sharedness
Browse files Browse the repository at this point in the history
  • Loading branch information
abrown committed Sep 3, 2024
1 parent 947c3a3 commit df11990
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions crates/wasm-smith/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ impl Module {

(HT::Concrete(a), HT::Abstract { shared, ty }) => {
let a_ty = &self.ty(a).composite_type;
if a_ty.shared == shared {
if a_ty.shared != shared {
return false;
}
match ty {
Expand All @@ -522,7 +522,7 @@ impl Module {

(HT::Abstract { shared, ty }, HT::Concrete(b)) => {
let b_ty = &self.ty(b).composite_type;
if shared == b_ty.shared {
if shared != b_ty.shared {
return false;
}
match ty {
Expand Down Expand Up @@ -1060,9 +1060,10 @@ impl Module {
.copied(),
);
}
let shared = self.config.shared_everything_threads_enabled && u.arbitrary()?;

Ok(HeapType::Abstract {
shared: false, // TODO: turn on shared attribute with shared-everything-threads.
shared,
ty: *u.choose(&choices)?,
})
}
Expand Down Expand Up @@ -2552,7 +2553,15 @@ pub(crate) fn arbitrary_table_type(
Some(module) => module.arbitrary_ref_type(u)?,
None => RefType::FUNCREF,
};
let shared = config.shared_everything_threads_enabled && u.arbitrary()?;
// Mark the table as shared if the element type is shared.
let shared = match element_type.heap_type {
HeapType::Abstract { shared, .. } => shared,
HeapType::Concrete(index) => {
let module = module.unwrap();
let ty = module.types.get(index as usize).unwrap();
ty.composite_type.shared
}
};

Ok(TableType {
element_type,
Expand Down

0 comments on commit df11990

Please sign in to comment.