Skip to content
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

[js-api] Allow creating i64 globals #827

Closed
rossberg opened this issue Jun 22, 2018 · 6 comments
Closed

[js-api] Allow creating i64 globals #827

rossberg opened this issue Jun 22, 2018 · 6 comments

Comments

@rossberg
Copy link
Member

The JS API does not yet support i64 for functions or globals because JS cannot represent int64.

However, there is no reason to disallow creating WebAssembly.Global instances of type i64. It is sufficient to disallow accessing them from JS through the getter and setter. After all, such objects can already be created indirectly by exporting an i64 global from a module.

I hence suggest the following relaxations:

  • The algorithm ToValueType does not throw on "i64" but return i64.
  • The algorithm DefaultValue does not throw on i64 but return (i64.const 0).

That way, a Global of type i64 can be created in JS but only with a default initialisation value.

Motivation: It is problematic for a generic linker, mocker or other module-level abstractions if they cannot externally create every possible export object (even if unusable in JS).

@littledan
Copy link
Collaborator

Given that BigInt is already relatively far along, I wonder if it would make sense to make this change together with the WebAssembly i64/BigInt integration proposal. This could leave the world with fewer states in the compatibility matrix to worry about. Anyway, @rossberg 's proposal doesn't seem so bad to me.

@rossberg
Copy link
Member Author

rossberg commented Jun 25, 2018

BigInt support is not going to be in 1.0. This suggestion is to tweak what we ship in 1.0, so not gonna change the size of the matrix.

@littledan
Copy link
Collaborator

If WebAssembly has already shipped to the web without this feature, it's part of the matrix even if the 1.0 document already includes the feature.

@rossberg
Copy link
Member Author

The Global constructor has not shipped in most browsers yet.

binji added a commit that referenced this issue Jun 27, 2018
@xtuc
Copy link
Contributor

xtuc commented Jul 12, 2018

This issue has been closed by #829.

During WebAssembly/meetings#268, we discussed about coercing values to/from i64 for function exports and globals but It's not covered by #829.

@rossberg
Copy link
Member Author

Right, closing this. Allowing coercions is a separate question.

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

No branches or pull requests

3 participants