Bug 250511
Summary: | JSValueGetType() is incorrect for BigInt values | ||
---|---|---|---|
Product: | WebKit | Reporter: | Kasper Isager Dalsgarð <kasperisager> |
Component: | JavaScriptCore | Assignee: | Yijia Huang <yijia_huang> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | d_degazio, mark.lam, ticaiolima, webkit-bug-importer, ysuzuki |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Local Build | ||
Hardware: | Mac (Apple Silicon) | ||
OS: | macOS 13 | ||
See Also: | https://bugs.webkit.org/show_bug.cgi?id=250719 | ||
Bug Depends on: | 273705 | ||
Bug Blocks: |
Kasper Isager Dalsgarð
JSValueGetType() currently has no path for values of type BigInt and therefore falls through to the object case, returning kJSTypeObject:
https://github.com/WebKit/WebKit/blob/8196614cb0623111b43d1041469eb3247e5623bb/Source/JavaScriptCore/API/JSValueRef.cpp#L51-L79
I imagine a kJSTypeBigInt value should be introduced and a path for jsValue.isBigInt() added.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/104194532>
Mark Lam
Hmmm, JSBigInt directly extends JSCell, and therefore, not is not a JSObject. We should fix this.
Kasper Isager Dalsgarð
On a related note, JSValueIsBigInt() would be great as well.
Kasper Isager Dalsgarð
The same goes for variants of JSValueMakeBigInt*() and JSValueToBigInt*(); those are sorely missed as well.
Mark Lam
Adding JSValueMakeBigInt*() and JSValueToBigInt*() is going to take a lot more time to make sure the API is correct.
Kasper Isager Dalsgarð
For converting BigInts to C primitives, there already seem to be private APIs available:
https://github.com/WebKit/WebKit/blob/4abc58df4642909ba616e53f76f7e69b18934b18/Source/JavaScriptCore/runtime/JSCJSValue.h#L312-L313
Mark Lam
(In reply to Kasper Isager Dalsgarð from comment #6)
> For converting BigInts to C primitives, there already seem to be private
> APIs available:
>
> https://github.com/WebKit/WebKit/blob/
> 4abc58df4642909ba616e53f76f7e69b18934b18/Source/JavaScriptCore/runtime/
> JSCJSValue.h#L312-L313
The complication isn't with the primitives. It's with getting the API correct e.g. for interactions with other API, for correctness, for security, for performance, etc. Designing that and testing it will take time.
Kasper Isager Dalsgarð
Noted! It also wasn't directly relevant to the initial bug report, so I'll open separate tickets.
Kasper Isager Dalsgarð
Is there any news on this?
Kasper Isager Dalsgarð
Do let me know if there's anything I can do to help get this fixed. I'd be more than happy to provide a patch as well. Thanks!
Yijia Huang
Pull request: https://github.com/WebKit/WebKit/pull/19251
Kasper Isager Dalsgarð
That's fantastic, thanks so much! That also deals with most of https://bugs.webkit.org/show_bug.cgi?id=250719, with the exception of conversion back to numbers.
Yijia Huang
*** Bug 250719 has been marked as a duplicate of this bug. ***
EWS
Committed 278275@main (c97a08d9e56f): <https://commits.webkit.org/278275@main>
Reviewed commits have been landed. Closing PR #19251 and removing active labels.
Yijia Huang
Reopened Bugzilla.
Failed Xcode build, tracking revert in https://bugs.webkit.org/show_bug.cgi?id=273705.
Yijia Huang
Pull request: https://github.com/WebKit/WebKit/pull/28121
EWS
Committed 278588@main (e8e344010871): <https://commits.webkit.org/278588@main>
Reviewed commits have been landed. Closing PR #28121 and removing active labels.