Conversation
As proposed in WebAssembly/shared-everything-threads#119. Add parsing, printing, and validation. The optimization passes will not yet preserve the semantics of publish instructions in general; a future change will have to augment EffectAnalyzer to model its effects correctly.
| // (local.set $p (publish (local.get $s))) | ||
| // (local.set $x (local.get $s)) | ||
| // `SimplifyLocals` could sink `publish` past `local.set $x`, moving | ||
| // the write of `$s` to `$x` before `publish`. |
There was a problem hiding this comment.
Wait, I'm not following. The write of s to x is fine, isn't it? Isn't the danger only writes to the heap object a local refers to?
There was a problem hiding this comment.
Possibly. I was thinking about this this morning and I'm actually not sure how this should work with respect to aliasing in locals. It's a question for Conrad, probably.
There was a problem hiding this comment.
Yeah, no, thinking about this more, writes to locals are definitely not a problem. The chain of address dependencies, data dependencies, and happens-before edges leading up to a read on another thread must start with a write of the published object that happens after the publish, not with the publish itself. So it's ok if that write after the publish has no data dependency on the publish, which means it's fine to move local.set of the published object before the publish.
I'll update the comment.
As proposed in WebAssembly/shared-everything-threads#119. Add parsing, printing, and validation. The optimization passes will not yet preserve the semantics of publish instructions in general; a future change will have to augment EffectAnalyzer to model its effects correctly.