-
-
Notifications
You must be signed in to change notification settings - Fork 57
Add support for BigInts and BigInt-based TypedArrays #184
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
Conversation
|
Time Change: +279.25ms (3%) Total Time: 8,247.5ms
ℹ️ View Unchanged
|
|
This needs conflicts to be resolved after |
|
Can we have a separate module for BigInt support instead of having a new feature flag BTW symbol support should be also enabled by an explicit option? We need to define the minimum supported ECMAScript edition, and guard for new features introduced after the edition. |
|
Time Change: -39ms (0%) Total Time: 19,157ms
View Unchanged
|
|
I would especially appreciate feedback on the new package name ( |
|
Module name candidates:
Note: The proposal name was JS-BigInt-integration |
|
How's about |
|
Ah, sorry, just saw your link to the proposal. 😅 Then I personally vote for |
|
For |
|
Is this ready for review by any chance? |
|
Yep! |
|
I prefer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a few nits. Great work! 👏
Co-Authored-By: Max Desiatov <[email protected]>
Co-Authored-By: Max Desiatov <[email protected]>
|
I wonder if we have to disable Safari WasmTransformer pass when |
|
I can also confirm that the issue is not reproducible with 95d0c4c, which is prior to the merge commit for this PR. |
|
That sounds good! Would we need to do anything on the JS side to correctly handle the previous APIs that now return BigInts? |
|
I haven't verified yet if disabling the pass fixes the issue with the latest JSKit |
Fixes #56.
Depends on #183In the
JavaScriptKitpackage, this PR:JSBigIntclass that makes it easy to convert betweenBigIntandInt64/UInt64values.i64values are signed, so I have to hack around that behavior forUInt64values+-*/etc) onJSBigIntinstances; however, we currently don’t have a way to invoke arbitrary operators in JS from Swift, and there are no function-based equivalents of the operators that we could access instead..fromJSValue()(this may cause a crash if the BigInt is outside of the bounds of the requested type, I think)Int64andUInt64toJSValueIn addition, a new package (tentatively named
JavaScriptKit_I64) includes:JSTypedArray<Int64>andJSTypedArray<UInt64>Int64andUInt64to aBigIntJSValueDoublevalue?BigIntJSValueint64ValueanduInt64Valueof aJSBigIntInt64(bigInt)/UInt64(bigInt)?JSBigIntfrom anInt64orUInt64also, it:
ConstructibleFromJSValueto reduce boilerplate code (using a Swift 5.5 feature)JSSymbol’sJSValueconversion APIs (oops!)setTimeoutfunction to be aDouble(since at least Node.js doesn’t support BigInt timeouts)JSValueKind.invalidsince it is unusedassertNeverhelper function in TypeScript to ensure switches are exhaustive