-
-
Notifications
You must be signed in to change notification settings - Fork 649
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
✂[Moving to Small PRs] Shared Memory and Atomic Memory Accesses support #278
✂[Moving to Small PRs] Shared Memory and Atomic Memory Accesses support #278
Conversation
Sync from origin
} | ||
if (!(typeArguments && typeArguments.length == 1)) { | ||
if (typeArguments && typeArguments.length) compiler.currentType = typeArguments[0]; | ||
compiler.error( |
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 think you could move on top and unify checking count of type arguments and print error.
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 will prevent catching further errors. typeArguments
and operands can be empty.
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.
We can definitely improve it. I kept the error checking in same style as load
, store
implementation.
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 will prevent catching further errors.
typeArguments
and operands can be empty.
I mean, you check this twice inside branches but may be better move out of branches and do this one level upper only once at first place?
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 saw it. There was a small issue below that error check. Typescript was complaining about typeArguments
may be undefined, so I left it like that. I will check other possibility to remove duplicate code.
@@ -149,6 +149,27 @@ declare function fmod(x: f64, y: f64): f64; | |||
/** Returns the 32-bit floating-point remainder of `x/y`. */ | |||
declare function fmodf(x: f32, y: f32): f32; | |||
|
|||
declare namespace Atomic { |
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.
What about use Atomics
instead Atomic
but only for namespace with generic methods? The same as provided Web API? This also takes effect to Atomics.exchange
and Atomics.compareExchange
.
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 guess it's better to align with WebAssembly Spec to avoid confusions. If required we could make alias functions for WebAPI but again WebAPI spec is not compatible with WASM spec. I would also skip Atomics.exchange
and Atomics.compareExchange
for now in favor of Atomic.xchg
and Atomic.cmpxchg
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.
Yeah, aliases sounds great for that
Sync from origin
initial and max memory set to sharedMemory
e15665b
to
0ce39e4
Compare
As I understand |
Yes, That's correct. |
May be it's better idea to implement |
@nidin I tried playing around with your branch and tried using wait and wake in chrome since it now supports threads, however, it seems to only support the other atomic instructions. I looked at the example from that article and it uses an imported wait and wake, which I think we'll have to do until their added. |
@willemneal Wait wake is in this branch |
…ait-wake-integration Feature/worker based threads wait wake integration
Atomic wait/wake feature added |
This follows the recent JavaScript name change, and was decided in the Nov 13 CG meeting.
Thank you so much for looking into this! Could we maybe split this into multiple parts to make it a little easier to grasp? For example, a first part could be to add the respective binaryen defintitions and internal module methods, a second could be the necessary changes to the compiler plus tests and a third could be adding an example? |
Definitely. I will do so.
…On Wed 9. Jan 2019 at 1:22 PM, Daniel Wirtz ***@***.***> wrote:
Thank you so much for looking into this! Could we maybe split this into
multiple parts to make it a little easier to grasp? For example, a first
part could be to add the respective binaryen defintitions and internal
module methods, a second could be the necessary changes to the compiler
plus tests and a third could be adding an example?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#278 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMGZmvxH52bbxL3HwjlMJhaaQvOXMoNks5vBd7rgaJpZM4W1AZc>
.
|
Features from this PR already merged to master from another PRs |
This PR will add Shared Memory and Atomic Memory Accesses support to AssemblyScript.
PR is not yet ready to merge.Closes #241
Syntax
Changes
1. Declare memory as shared
new compiler argument
--sharedMemory=MAXIMUM_SHARED_MEMORY
2. Load/Store
i32.atomic.load8_u
: atomically load 1 byte and zero-extend i8 to i32i32.atomic.load16_u
: atomically load 2 bytes and zero-extend i16 to i32i32.atomic.load
: atomically load 4 bytes as i32i64.atomic.load8_u
: atomically load 1 byte and zero-extend i8 to i64i64.atomic.load16_u
: atomically load 2 bytes and zero-extend i16 to i64i64.atomic.load32_u
: atomically load 4 bytes and zero-extend i32 to i64i64.atomic.load
: atomically load 8 bytes as i64i32.atomic.store8
: wrap i32 to i8 and atomically store 1 bytei32.atomic.store16
: wrap i32 to i16 and atomically store 2 bytesi32.atomic.store
: (no conversion) atomically store 4 bytesi64.atomic.store8
: wrap i64 to i8 and atomically store 1 bytei64.atomic.store16
: wrap i64 to i16 and atomically store 2 bytesi64.atomic.store32
: wrap i64 to i32 and atomically store 4 bytesi64.atomic.store
: (no conversion) atomically store 8 bytes3. Read-Modify-Write
4. Compare Exchange
5. Wait / Wake
The wait operator take three operands: an address operand, an expected value,
and a relative timeout in nanoseconds as an
i64
. The return value is0
,1
, or2
, returned as ani32
.timeout
valuetimeout
< 0timeout
<= maximum signed i64 valuetimeout
nanoseconds0
1
2
Note : i64.wait/wake is not implemented in chrome.