Skip to content
This repository was archived by the owner on Nov 3, 2021. It is now read-only.
This repository was archived by the owner on Nov 3, 2021. It is now read-only.

[js-api] WebAssembly.Table.prototype.grow and a fill value #22

Closed

Description

@lars-t-hansen

The envisioned table.grow instruction takes a required fill value as a second argument. We should similarly change WebAssembly.Table.prototype.grow to accept a fill value, indeed for non-nullable element types we must have a fill value. Here are some notes about that.

Backward compatibility concerns when the table is table-of-anyfunc:

  • the second argument must be optional
  • the default value of the optional second argument must be null
  • if the second argument is present but is not a function value that can be stored, then it must be ignored

For table-of-anyref it is probably most correct if the default value for the optional second argument is null, not undefined, since null is a value that is in wasm, unlike undefined. (This matters only because undefined is representable as an anyref value and is thus a candidate at least in principle.) FWIW, the table.grow instruction cannot talk about undefined values without getting them from the host, but it can synthesize null. A JS caller to WebAssembly.Table.prototype.grow() can pass an undefined value explicitly as the second argument to initialize new slots with that value.

Long-term it's inevitable that the behavior of W.T.p.grow depends on the table type anyway; for non-nullable element types there can be no default, for example. We could choose now to require the second argument also for anyref tables, we would just have to leave anyfunc tables as a special case.

Activity

  1. changed the title [-]WebAssembly.Table.prototype.grow and an initializer argument[/-] [+]WebAssembly.Table.prototype.grow and a fill value[/+] on Nov 30, 2018
  2. lars-t-hansen commented on Nov 30, 2018

    @lars-t-hansen
    ContributorAuthor

    I guess accepting a second argument here for table-of-anyfunc is technically incompatible with existing code that does pass an exported wasm function as the second argument, since that argument would previously be ignored but now will not be.

  3. rossberg commented on Nov 30, 2018

    @rossberg
    Member

    Agreed with this proposal. For non-nullable table types leaving of the default should cause a TypeError, of course, but the simplest way to achieve that probably is to define null as the default for all reference types in the API. Then the later check will throw the error anyway.

    The ES spec has added additional arguments to some of its functions in the past, so we should be okay doing the same.

  4. lukewagner commented on Dec 17, 2018

    @lukewagner
    Member

    Just to confirm: do we all agree it's ok to break backwards-compatibility by changing the case where a non-exported-wasm-function JS value is passed as the second argument to Table.prototype.grow from silently ignoring to throwing?

    I ask because @Ms2ger judiciously wrote a wpt for exactly this case that fails if we make this breaking change, but I expect (and we can verify in FF by immediately landing a throw-if-passing-any-second-argument patch ahead of full bulk-operations) that this breaking change won't actually break web content. If the assumption is correct, that means we'd change the wpt to test for the throwing behavior.

    Make sense to everyone? [cc @Ms2ger @littledan ]

  5. Ms2ger commented on Dec 18, 2018

    @Ms2ger
    Contributor

    It makes sense to me to throw on any invalid values here. Please do update the test, and add one for the three-argument case :)

  6. changed the title [-]WebAssembly.Table.prototype.grow and a fill value[/-] [+][js-api] WebAssembly.Table.prototype.grow and a fill value[/+] on Nov 15, 2019
  7. rossberg commented on Jan 16, 2020

    @rossberg
    Member

    It's in the embedder interface, but the JS API still needs to add the init argument.

    @littledan, would you be willing to look into this?

  8. wingo commented on Jan 17, 2020

    @wingo
    Contributor

    I'll take it if that works for y'all. Am out of the office next week but will pick it up the week after.

  9. rossberg commented on Jan 19, 2020

    @rossberg
    Member

    Thanks @wingo. By any chance, would you be willing to also look into #51 and #67? Those seem to be the other open issues around the JS API. Both of them should be fairly easy to fix.

  10. rossberg commented on Feb 8, 2020

    @rossberg
    Member

    @wingo, any update on this? Would be good to have this fixed before the meeting on Tuesday.

  11. wingo commented on Feb 10, 2020

    @wingo
    Contributor

    Hi, sorry for the delay; didn't realize how much travel would discombobulate me :P No update currently, but I will switch to this task to see if I can finish by tomorrow.

  12. added 3 commits that reference this issue on Feb 11, 2020
    c7e3087
    b2310ef
    7adf9d4
  13. lars-t-hansen commented on Feb 25, 2020

    @lars-t-hansen
    ContributorAuthor

    @wingo, any update?

  14. Ms2ger commented on Feb 25, 2020

    @Ms2ger
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions