Skip to content

Lock-free guarantees for 8- and 16-bit atomics #19

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

Closed
binji opened this issue May 26, 2017 · 4 comments
Closed

Lock-free guarantees for 8- and 16-bit atomics #19

binji opened this issue May 26, 2017 · 4 comments
Labels

Comments

@binji
Copy link
Member

binji commented May 26, 2017

There is some discussion on the LLVM issue list about lock-free guarantees: https://bugs.llvm.org/show_bug.cgi?id=33146

This was previously discussed a long time ago here: WebAssembly/design#300

Should we guarantee that 8-bit and 16-bit atomics are lock-free?

@binji binji added the question label May 26, 2017
@binji binji changed the title Lock-free guarantees for 8 and 16 byte atomics Lock-free guarantees for 8- and 16-bit atomics May 26, 2017
@lars-t-hansen
Copy link

It seems silly to do this if the reason is that LLVM does not have the internal structures to represent the WebAssembly semantics.

I also note that it is possible to move to lock-freedom later if we don't spec that now, but much less simple to move to non-lock-freedom if we prematurely spec lock-freedom now...

Finally, one principle we've had for wasm atomics has been to stay compatible with JS, which does not guarantee lock-freedom for 8-bit and 16-bit data at this time. If we do move to lock-free 8-bit and 16-bit atomics for wasm now i'd really like to see a commitment from somebody to push that through TC39. Won't be a lot of work but should be done. Effectively a wasm lock-free requirement imposes that on the SAB implementation in any browser, which in turn means JS in all those browsers will have lock-free atomics whether ES specs that or not.

(Personally I'd prefer to spend our cycles on other topics than this until we have a threading MVP.)

@lars-t-hansen
Copy link

All that said (and counter to what is asserted in the May meeting text), I did conclude some time ago that ARM, MIPS, POWER, and x86 are all fine: tc39/proposal-ecmascript-sharedmem#10 (comment). For ES there was the question of very early ARMv6, and of course the corner cases that may exist (WebAssembly/design#300 (comment)), but I'm unconcerned about those in the context of wasm.

@binji
Copy link
Member Author

binji commented May 29, 2017

Sorry, there was a lot of discussion about this topic, and I was having a hard time finding a resolution. Thanks for the pointers to these!

@binji
Copy link
Member Author

binji commented Jun 6, 2017

We agreed in the CG meeting to not mention lock freedom in the WebAssembly spec (at least not in a normative way). The idea is to provide atomic accesses for 8, 16, 32, and 64 bit sizes. We don't say how the implementation will make them atomic -- it may use an atomic instruction or an implicit lock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants