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

Conversation

kripken
Copy link
Member

@kripken kripken commented May 29, 2025

No description provided.

@kripken kripken requested a review from tlively May 29, 2025 21:25
return;
}
auto array = curr->ref->type.getHeapType().getArray();
self()->noteSubtype(curr->expected, array.element.type);
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem right. The expected value should be allowed to be a supertype of the element type, so it should only be required to be a subtype of eq. I see this is wrong for StructCmpxchg as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed both. Though it seems the spec could be more strict here..?

Copy link
Member

Choose a reason for hiding this comment

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

This way is actually better for us. See the discussion at WebAssembly/shared-everything-threads#92.

Comment on lines 1385 to 1387
// 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);
Copy link
Member

Choose a reason for hiding this comment

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

This can be just replacement->type. I see this is wrong for StructCmpxchg as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed both.

auto type = ht->getArray().element.type;
note(&curr->ref, Type(*ht, Nullable));
note(&curr->index, Type::i32);
note(&curr->expected, type);
Copy link
Member

Choose a reason for hiding this comment

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

This should be eqref if type is a reference and type otherwise. I see this is wrong for StructCmpxchg as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed both.

Copy link
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

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

LGTM % last comment

@@ -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.

@kripken kripken merged commit 4f9374c into WebAssembly:main Jun 2, 2025
16 checks passed
@kripken kripken deleted the array.rmw branch June 2, 2025 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants