Skip to content

An initial overview of threads - #1

Merged
binji merged 10 commits into
masterfrom
overview
May 9, 2017
Merged

binji merged 10 commits into
masterfrom
overview

Conversation

@binji

@binji binji commented Apr 18, 2017

Copy link
Copy Markdown
Member

For now this is just copied from WebAssembly/design#1019, since I haven't had a chance to work on the proposal much. I'll address some of the feedback there soon.

@binji

binji commented Apr 28, 2017

Copy link
Copy Markdown
Member Author

I've updated the overview to not reference things from the design repo. I've also tried to add some basic spec changes, though perhaps those would be better to just do directly in the rst files.

Still haven't gotten around to the JavaScript-stuff.

@AndrewScheidecker

Copy link
Copy Markdown
Contributor

The alignment immediate on these operators is effectively ignored, right? If so, I think it should be removed (or specification of unnatural alignment should be made invalid).

@jfbastien

Copy link
Copy Markdown
Member

The alignment immediate on these operators is effectively ignored, right? If so, I think it should be removed (or specification of unnatural alignment should be made invalid).

Elsewhere we discussed trapping if not at least naturally-aligned. Given that, I tend to agree that we could just drop alignment entirely.

@binji

binji commented Apr 28, 2017

Copy link
Copy Markdown
Member Author

Makes sense, but I believe we were going to use the alignment u32 as the place to add a flag/index for accessing memories other than 0, right? So perhaps we should just keep the alignment but require it to be natural.

limits ::= 0x00 n:u32 => {min n, max e, notshared}
0x01 n:u32 m:u32 => {min n, max m, notshared}
0x11 n:u32 m:u32 => {min n, max m, shared}
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the shared-unbounded case deliberately omitted? (i.e. 0x10 n:u32 => {min n, max e, shared})

And what is the text syntax?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is deliberately omitted. I can't remember what issue we discussed it, but it simplifies things if we can just assume the VM will reserve address space for the maximum size. Though I suppose if grow_memory is just best effort anyway, maybe it doesn't really make a difference.

Haven't really thought of a text syntax yet. I guess it could just be:

(memory <min> <max> shared)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're worried about having to suspend all threads if we need to physically move the memory. If max is specified we know we'll never need to move the memory because the virtual memory was pre-allocated, and only page protections or bounds need to be changed which doesn't require thread suspension.

It's easy to add later, so I'm not too worried. It would be good to document, and point at the experience from NaCl. IIRC the issues around suspension were documented in its codebase.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't seem to find the place in the NaCl source that talks about the difficulty in thread suspension. But I'll add a comment about it generically, and we can add further references later.

Comment thread proposals/threads/Overview.md Outdated
memory. The operators have sequentially consistent ordering.

Both wake and wait operators trap if the effective address of either operator
is misaligned or out-of-bounds.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Misaligned" for wake means 4 byte aligned, right? This should be spelled out, or perhaps wake shouldn't care about alignment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I've explicitly mentioned wake requires 4-byte alignment.

Comment thread proposals/threads/Overview.md Outdated

`grow_memory` of a shared linear memory is allowed, but may fail if the new
size is greater than the specified maximum size, or if reserving the additional
memory fails. All agents in the executing agent's cluster will have access to

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wording makes it a little unclear that grow_memory always fails if the new size is greater than the specified maximum size, which is what I assume is intended here. Possible wording suggestion:

grow_memory of a shared linear memory is allowed. Like non-shared memory, it fails if the new size is greater than the memory's maximum size, and it may also fail if reserving the additional memory fails.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've used this wording.

@binji

binji commented May 3, 2017

Copy link
Copy Markdown
Member Author

OK, first pass of the JS API changes. PTAL

Comment thread proposals/threads/Overview.md Outdated

If `m` is shared, any attempts to [detach][] `buffer` shall throw a
[TypeError][]. Otherwise, any attempts to [detach][] `buffer` _other_ than the
detachment performed by `m.grow` shall throw a [TypeError][].

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To confirm: shared memory grow detatches the SAB?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I guess this should be clearer. The "Otherwise" is meant to refer to when m is not shared; a SAB is never detached.

Comment thread proposals/threads/Overview.md Outdated

However, the `memoryDescriptor` now will check for a `shared` property:

If [`HasProperty`][](`"shared"`), then let `shared` be

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usual ES conventions is to not use HasProperty in such situations (e.g. because it is an observable extra call with proxies), but handle undefined as a result of Get appropriately. Fortunately, undefined, already converts to false, so you can just drop the check without substitute.

@rossberg

rossberg commented May 5, 2017

Copy link
Copy Markdown
Member

Wait, when has the opcode prefix changed to F0? As long as the only motivation for that remains being silly, it still is not worth the price of unnecessary opcode space fragmentation IMO.

@binji

binji commented May 5, 2017

Copy link
Copy Markdown
Member Author

r.e. opcode prefix: I don't really care either way, but both you and @jfbastien have argued for different codes. It doesn't seem like there's a strong technical argument either way, and we don't have a policy for opcode layout. Perhaps we should? This sort of thing is going to keep coming up.

@binji

binji commented May 8, 2017

Copy link
Copy Markdown
Member Author

Aside from the opcode prefix, are there any other issues that I should address before landing this overview?

@jfbastien jfbastien left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a first draft this lgtm.

@binji

binji commented May 9, 2017

Copy link
Copy Markdown
Member Author

OK, landing w/ lgtm.

@binji
binji merged commit 4a6b036 into master May 9, 2017
@binji
binji deleted the overview branch May 9, 2017 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants