-
-
Notifications
You must be signed in to change notification settings - Fork 648
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
Built-in atomic functions added #440
Conversation
Extended `_BinaryenAddMemoryImport` and `_BinaryenSetMemory` functions with `shared: bool` argument This will configure WASM memory as shared.
Updated AssemblyScript contributions author list
`shared:bool` argument added to `addMemoryImport` and `setMemory` functions
@@ -2844,7 +3333,18 @@ function deferASM( | |||
valueType: Type, | |||
reportNode: Node | |||
): ExpressionRef { | |||
var prototype = assert(compiler.program.elementsLookup.get(name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elementsLookup
should also contain namespace members here, like both Atomic
and Atomic.load
etc. Is there a bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will cross check. Atomic.load
was not in elementsLookup
but it was a few months ago.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason namespace members are undefined
in elementsLookup
compiler.program.elementsLookup.get("Atomic.load")
return undefined
compiler.program.elementsLookup.get("Atomic")
return
MapIterator {
'load',
'store',
'add',
'sub',
'and',
'or',
'xor',
'xchg',
'cmpxchg',
'wait',
'notify' }
if (offset < 0) { // reported in evaluateConstantOffset | ||
return module.createUnreachable(); | ||
} | ||
compiler.currentType = typeArguments[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems typeArguments[0]
used 5 times so it will be great cache it to variable and may be in upper scope
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will change it.
if (!(typeArguments && typeArguments.length == 1)) { | ||
compiler.error( | ||
DiagnosticCode.Expected_0_type_arguments_but_got_1, | ||
reportNode.range, "1", typeArguments ? typeArguments.length.toString(10) : "0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.toString(10)
is unnecessary. Just use toString()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This too.
btw you could try turn on threads for latest node via |
How do threads work with node? In the Browser there are web workers, but I thought node was single threaded. |
Mostly the same for now: https://nodejs.org/api/worker_threads.html |
I see. Totally makes sense. But also will great have small test cases of functionality present in this PR. Or add it in separate PR |
Atomic operations won't compile without shared memory support in compiler. It will come in next PR. followed by test cases. |
Got it! |
Great, thanks! :) |
Built-in atomic functions added for
SharedArrayBuffer
.List of functions