This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Support for atomic.wait / atomic.wake instructions
ClosedPublic

Authored by aheejin on Jul 16 2018, 12:14 PM.

Diff Detail

Event Timeline

aheejin created this revision.Jul 16 2018, 12:14 PM
aheejin edited the summary of this revision. (Show Details)Jul 16 2018, 12:15 PM
aheejin edited the summary of this revision. (Show Details)
aheejin edited the summary of this revision. (Show Details)Jul 16 2018, 12:17 PM
aheejin updated this revision to Diff 155959.Jul 17 2018, 1:33 PM
  • Type fix
aheejin planned changes to this revision.Jul 26 2018, 4:17 PM

Should've included all sorts of other memargs.

aheejin updated this revision to Diff 158018.Jul 30 2018, 11:15 AM
  • Add support for various memargs
aheejin updated this revision to Diff 158022.Jul 30 2018, 11:22 AM

clang-format

Does atomic.wake possibly load the given address? It is marked as such for now to be safe. Would it have any problems, or would it be unnecessary?

aheejin planned changes to this revision.Jul 30 2018, 11:27 AM

Should make it return true on isAtomic() I guess

I guess there's no sane way to make MachineMemOperand of wait and wake instructions return true on isAtomic() anyway. First, LLVM currently does not seem to provide atomic memory intrinsic other than few predefined target-independent intrinsics, and there's no code that depends on MachineMemOperand::isAtomic() in the backend passes anyway.

aheejin requested review of this revision.Jul 31 2018, 5:10 PM

Note that in JS, atomics.wake is now atomics.notify (https://github.com/tc39/ecma262/pull/1220). So we should use the new terminology for new and internal stuff. Since there's no legacy yet (except maybe in Binaryen's and WABT's text parser) hopefully LLVM can just use "notify" everywhere.

I think wake does not load the given address. the list of waiters is outside of the memory and invisible to LLVM, it just happens to share the same index space. So I think hasSideEffects is the right way to model that.

include/llvm/IR/IntrinsicsWebAssembly.td
75

Same signature adjustments as suggested in the clang CL.

aheejin updated this revision to Diff 158557.Aug 1 2018, 9:40 AM
  • wake -> notify / etc

Do you think we should also suggest to change wake to notify in the thread proposal?

include/llvm/IR/IntrinsicsWebAssembly.td
75

I added some comments in that CL, PTAL.

I would imagine that's already on Ben's plate to do sometime, but yes it should be changed to match JS.

include/llvm/IR/IntrinsicsWebAssembly.td
75

Yeah, so this signature would be unchanged then, since there's no signed/unsigned distinction in the IR either.

dschuff accepted this revision.Aug 1 2018, 4:58 PM
This revision is now accepted and ready to land.Aug 1 2018, 4:58 PM
aheejin updated this revision to Diff 158672.Aug 1 2018, 5:47 PM

Added MOVolatile flags to instructions and added comments

aheejin added a comment.EditedAug 1 2018, 5:51 PM

I added MOVolatile flags to instructions, because, currently LLVM atomic instructions are marked as such. References: 1 2
I also added some comments on why wake is marked as MOLoad. PTAL

Still looks good 👍

This revision was automatically updated to reflect the committed changes.