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

BigInt support #56

Closed
MaxDesiatov opened this issue Sep 16, 2020 · 3 comments · Fixed by #184
Closed

BigInt support #56

MaxDesiatov opened this issue Sep 16, 2020 · 3 comments · Fixed by #184
Labels
enhancement New feature or request

Comments

@MaxDesiatov
Copy link
Contributor

BigInt is supported in Safari 14 on both macOS Catalina/Big Sur and iOS 14, makes perfect sense to support it on our side too, especially to allow proper handling of Int64.

Need to be careful about browser compatibility though. Should JavaScriptKit just fatalError on older browsers when users attempt to use JSBigInt in their code?

Also a good case for a pitch for proper browser versioning in Swift, I'll open a separate toolchain issue for it.

@j-f1
Copy link
Member

j-f1 commented Sep 16, 2020

I was thinking about doing this earlier today, and was trying to figure out how Int64/UInt64 fit into this. Ideally we’d be able to access Big(U)Int64Array from Swift using the existing TypedArray infrastructure but I’m not sure how passing the value across the bridge would work — do we just add two more JSValue types for Int64 and UInt64?

@MaxDesiatov
Copy link
Contributor Author

Sadly, BigInt64Array isn't supported even in Safari 14. ☹️ Maybe still worth implementing it, just need to be even more careful with runtime checks?

@kateinoigakukun
Copy link
Member

kateinoigakukun commented Sep 16, 2020

BigInt is now supported on Safari, but the latest WebKit doesn't allow to have i64 on the signature of imported function.
For this reason, I had to polyfill wasi functions that have i64 on its interface. https://github.com/kateinoigakukun/swiftwasm-pad/tree/master/Frontend/Sources/i64_polyfill

See also: WebKit test case https://github.com/WebKit/webkit/blob/3a6be938ed0ede574ca96575dbe69f572269c819/JSTests/wasm/function-tests/function-import-return-value.js#L130-L184

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants