Skip to content

Implement tables & multiple memories #316

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

Merged
merged 6 commits into from
Aug 12, 2016
Merged

Implement tables & multiple memories #316

merged 6 commits into from
Aug 12, 2016

Conversation

rossberg
Copy link
Member

@rossberg rossberg commented Aug 4, 2016

As of WebAssembly/design#682. Still misses import/export abilities.

This changes & extends the S-expression syntax for tables and memories in the following way:

<elem_type>: anyfunc
<table>:     (table <nat> <nat>? <elem_type>)
<memory>:    (memory <nat> <nat>?)
<elem>:      (elem <expr> <var>*)
<data>:      (data <expr> <string>*)

In particular, memory segments are no longer part of the memory definition, in anticipation of the ability to import memory. Same for tables. This also mirrors the Wasm section structure more closely.

However, it is pretty tedious to count table elements in the common case, so the following shorthand is available:

(table <elem_type> (elem <var>*))    ;; = (table <size> <size> <elem_type>) (elem (i32.const 0) <var>*)

which pretty much behaves like the previous table syntax.
For symmetry, I introduced the analogous shorthand for memories, which turns out to be useful in tests as well:

(memory (data <string>*))   ;; = (memory <size> <size>) 
(data (i32.const 0) <string>*)

where <size> is the strings' total length in (rounded up) page units.

In the future, we can extend this syntax to name tables and memories, e.g.:

<table>:   (table <name>? <nat> <nat>? <elem_type>)
<memory>:  (memory <name>? <nat> <nat>?)
<elem>:    (elem <var>? <expr> <var>*)
<data>:    (data <var>? <expr> <string>*)

@kripken
Copy link
Member

kripken commented Aug 4, 2016

What is the plan with the stack branch - will this be merged there as well as to binary-0xc? Or will stack eventually be merged to binary-0xc without doing that first?

@rossberg
Copy link
Member Author

rossberg commented Aug 4, 2016

Excellent question. I meant to merge everything into binary-0xc eventually. But I'm still cleaning up the stack branch somewhat, and I suppose reviewing it may also take some time. So I didn't want everything else to block on that.

Guess that means that I gonna have a merge-conflict fest at some point...

@kripken
Copy link
Member

kripken commented Aug 4, 2016

In the tests it looks like data can either be nested in memory or not (address.wast vs the others that I looked at). What is the difference?

@rossberg
Copy link
Member Author

rossberg commented Aug 4, 2016

See the first comment above. ;)

@kripken
Copy link
Member

kripken commented Aug 4, 2016

Ok, sorry, I thought it was just about tables.

@lukewagner
Copy link
Member

The s-expr changes lgtm

@lukewagner
Copy link
Member

I think we also need new syntax for importing a tables/memories; we currently use:
( import <name>? <string> <string> ( table <nat> <nat>? <elem_type> ) )
( import <name>? <string> <string> ( memory <nat> <nat>? ) )

@rossberg
Copy link
Member Author

@lukewagner, yes, as noted in the comment, this PR does not yet implement imports/exports (just like the PR #313 for globals). WebAssembly/design#682 is pretty large a change, so I wanted to divide the changes somewhat.

@rossberg
Copy link
Member Author

Any concerns about landing this?

@lukewagner
Copy link
Member

righto, generally lgtm

@rossberg rossberg merged commit dfccff3 into binary-0xc Aug 12, 2016
@rossberg rossberg deleted the memories branch August 12, 2016 12:40
ngzhian added a commit to ngzhian/spec that referenced this pull request Nov 4, 2021
v8x16.shuffle and v8x16.swizzle is now i8x16.shuffle and i8x16.swizzle
respectively.

Fixed WebAssembly#316.
rossberg pushed a commit that referenced this pull request Jul 23, 2024
This updates `basic.tentative.any.js` and `identity.tentative.any.js`
tests to use the new instructions (`try_table` and `throw_ref`). In
addition to converting existing tests to use the new instruction while
maintaining the semantics, I added a new test in
`basic.tentative.any.js` that makes use of all four `catch` clause
variants to show all catch clauses works well in JS API tests.

These new tests reauire `--js-flags=--experimental-wasm-exnref` argument
to chrome, which is not currently supported in WPT out of the box. I've
instead confirmed these run with chrome web tests infrastructure
(https://chromium.googlesource.com/chromium/src/+/HEAD/docs/testing/web_tests.md#Running-Web-Tests).
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.

3 participants