Skip to content

[Shared-Everything] ArrayRMW and ArrayCmpxchg #7632

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

Merged
merged 35 commits into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/ir/child-typer.h
Original file line number Diff line number Diff line change
Expand Up @@ -997,8 +997,9 @@ template<typename Subtype> struct ChildTyper : OverriddenVisitor<Subtype> {
const auto& fields = ht->getStruct().fields;
assert(curr->index < fields.size());
note(&curr->ref, Type(*ht, Nullable));
note(&curr->expected, fields[curr->index].type);
note(&curr->replacement, fields[curr->index].type);
auto type = fields[curr->index].type;
note(&curr->expected, type.isRef() ? Type(HeapType::eq, Nullable) : type);
note(&curr->replacement, type);
}

void visitArrayNew(ArrayNew* curr) {
Expand Down Expand Up @@ -1151,7 +1152,7 @@ template<typename Subtype> struct ChildTyper : OverriddenVisitor<Subtype> {
auto type = ht->getArray().element.type;
note(&curr->ref, Type(*ht, Nullable));
note(&curr->index, Type::i32);
note(&curr->expected, type);
note(&curr->expected, type.isRef() ? Type(HeapType::eq, Nullable) : type);
note(&curr->replacement, type);
}

Expand Down
4 changes: 2 additions & 2 deletions src/ir/subtype-exprs.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ struct SubtypingDiscoverer : public OverriddenVisitor<SubType> {
return;
}
const auto& fields = curr->ref->type.getHeapType().getStruct().fields;
self()->noteSubtype(curr->expected, fields[curr->index].type);
self()->noteSubtype(curr->expected, Type(HeapType::eq, Nullable));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should also only be if the field type is a reference.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

self()->noteSubtype(curr->replacement, fields[curr->index].type);
}
void visitArrayNew(ArrayNew* curr) {
Expand Down Expand Up @@ -411,7 +411,7 @@ struct SubtypingDiscoverer : public OverriddenVisitor<SubType> {
return;
}
auto array = curr->ref->type.getHeapType().getArray();
self()->noteSubtype(curr->expected, array.element.type);
self()->noteSubtype(curr->expected, Type(HeapType::eq, Nullable));
self()->noteSubtype(curr->replacement, array.element.type);
}
void visitRefAs(RefAs* curr) {
Expand Down
8 changes: 2 additions & 6 deletions src/wasm/wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1256,9 +1256,7 @@ void StructCmpxchg::finalize() {
replacement->type == Type::unreachable) {
type = Type::unreachable;
} else if (ref->type.isNull()) {
// Like StructRMW, but the most precise possible field type is the LUB of
// the expected and replacement values.
type = Type::getLeastUpperBound(expected->type, replacement->type);
type = replacement->type;
} else {
type = ref->type.getHeapType().getStruct().fields[index].type;
}
Expand Down Expand Up @@ -1382,9 +1380,7 @@ void ArrayCmpxchg::finalize() {
replacement->type == Type::unreachable) {
type = Type::unreachable;
} else if (ref->type.isNull()) {
// Like ArrayRMW, but the most precise possible field type is the LUB of
// the expected and replacement values.
type = Type::getLeastUpperBound(expected->type, replacement->type);
type = replacement->type;
} else {
type = ref->type.getHeapType().getArray().element.type;
}
Expand Down
Loading