Skip to content

Conversation

@tlively
Copy link
Member

@tlively tlively commented Jul 16, 2024

Normally, values of different types can never compare equal to each
other, but since i31refs are not actually allocations, ref.eq has no
way to differentiate a shared i31ref and an unshared i31ref with the
same value, so it will report them as equal. Update the implementation
of value equality to reflect this correctly.

Normally, values of different types can never compare equal to each
other, but since i31refs are not actually allocations, `ref.eq` has no
way to differentiate a shared i31ref and an unshared i31ref with the
same value, so it will report them as equal. Update the implementation
of value equality to reflect this correctly.
@tlively tlively requested a review from kripken July 16, 2024 18:20
@kripken
Copy link
Member

kripken commented Jul 16, 2024

How does the spec define this? I'm curious to understand what "not actually an allocation" translates to in spec-lese.

@tlively
Copy link
Member Author

tlively commented Jul 16, 2024

The spec uses syntactic equality on reference values, most of which are of the form ref.XXX XXXaddr. But for i31, the reference values are of the form ref.i31 u31, so we will have the formal semantics of ref.i31 and ref.i31_shared both produce identical values of that form.

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

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

I see, thanks!

@tlively tlively merged commit 9de9d05 into main Jul 16, 2024
@tlively tlively deleted the threads-eq-i31 branch July 16, 2024 20:30
tlively added a commit that referenced this pull request Jul 17, 2024
#6752)"

Allowing Literals with different types to compare equal causes problems
for passes that want equality to mean real equality, e.g. because they
are using literals as map keys or because they otherwise need to use
them interchangeably.

At a minimum, we would need to differentiate a `refEq` operation where
mixed-shareability i31refs can compare equal from physical equality on
Literals, but there is also appetite to disallow mixed-shareability
ref.eq at the spec level. See
WebAssembly/shared-everything-threads#76.
tlively added a commit that referenced this pull request Jul 17, 2024
#6752)" (#6761)

Allowing Literals with different types to compare equal causes problems
for passes that want equality to mean real equality, e.g. because they
are using literals as map keys or because they otherwise need to use
them interchangeably.

At a minimum, we would need to differentiate a `refEq` operation where
mixed-shareability i31refs can compare equal from physical equality on
Literals, but there is also appetite to disallow mixed-shareability
ref.eq at the spec level. See
WebAssembly/shared-everything-threads#76.
@gkdn gkdn mentioned this pull request Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants