Bug 190800

Summary: [JSC] Implement BigInt64Array and BigUint64Array
Product: WebKit Reporter: Caio Lima <ticaiolima>
Component: JavaScriptCoreAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: annulen, chi187, ews-watchlist, gyuyoung.kim, hao.x.li, hi, joepeck, johann.hemmann, keith_miller, lars.sonchocky-helldorf, mark.lam, msaboff, puurtuur, ross.kirsling, ryuan.choi, saam, sarah, sergio, tzagallo, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 179001    
Attachments:
Description Flags
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch
none
Patch
none
Patch
none
Patch ross.kirsling: review+

Description Caio Lima 2018-10-22 11:52:08 PDT
...
Comment 1 Yusuke Suzuki 2020-05-05 03:46:26 PDT
Because we need to view contiguous int64_t* / uint64_t* memory region via this view, the storage should be just byte sequence. And [] access should wrap the result with JSBigInt when it is accessed from JS world.
Comment 2 lars.sonchocky-helldorf 2020-05-15 13:56:53 PDT
This would be nice to have for that: https://github.com/takahirox/riscv-rust/issues/115
Comment 3 Hao Li 2020-06-17 22:47:59 PDT
We also have the requirement for BigUint64Array in WebGPU: https://github.com/gpuweb/gpuweb/issues/866
Comment 4 johann.hemmann 2020-06-19 06:57:25 PDT
Generally it would be helpful for all projects using wasm_bindgen (https://github.com/rustwasm/wasm-bindgen), so also for the jsapi of the rav1e (https://github.com/xiph/rav1e/tree/master/rav1e_js).
Comment 5 Slim Lim 2020-12-03 23:40:38 PST
Echoing the previous comment, lack of BigUint64Array support means that applications using wasm-bindgen cannot run at all in Safari. This is especially problematic for targeting the iPad.
Comment 6 Yusuke Suzuki 2021-01-30 00:35:08 PST
Created attachment 418810 [details]
Patch
Comment 7 Yusuke Suzuki 2021-01-30 00:44:23 PST
Created attachment 418811 [details]
Patch
Comment 8 Yusuke Suzuki 2021-01-30 01:01:36 PST
Created attachment 418812 [details]
Patch
Comment 9 Yusuke Suzuki 2021-01-30 01:47:10 PST
Created attachment 418813 [details]
Patch
Comment 10 Yusuke Suzuki 2021-01-30 02:29:08 PST
Created attachment 418814 [details]
Patch
Comment 11 Yusuke Suzuki 2021-01-31 00:35:41 PST
Created attachment 418821 [details]
Patch
Comment 12 Ross Kirsling 2021-02-01 11:22:35 PST
Comment on attachment 418821 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=418821&action=review

r=me, this is awesome!

> Source/JavaScriptCore/runtime/AtomicsObject.h:65
> +JSArrayBufferView* validateTypedArray(JSGlobalObject*, JSValue);

This seems kind of weird? AtomicsObject.cpp needs to include JSArrayBufferView.h anyway, doesn't it?

> Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h:98
> +    using Adaptor = PassedAdaptor;

What's the purpose of this alias?

> Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h:462
> +    if constexpr (Adaptor::canConvertToJSQuickly)

Cool!

> JSTests/test262/expectations.yaml:831
> +test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js:
> +  default: 'TypeError: Invalid argument type in ToBigInt operation (Testing with BigInt64Array.)'
> +  strict mode: 'TypeError: Invalid argument type in ToBigInt operation (Testing with BigInt64Array.)'
> +test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js:
> +  default: 'Test262Error: throws a TypeError getting a value from the detached buffer Expected a TypeError to be thrown but no exception was thrown at all (Testing with BigInt64Array.)'
> +  strict mode: 'Test262Error: throws a TypeError getting a value from the detached buffer Expected a TypeError to be thrown but no exception was thrown at all (Testing with BigInt64Array.)'

Do you want to submit the patch for these or would you prefer that I do it?
Comment 13 Yusuke Suzuki 2021-02-01 12:44:29 PST
Comment on attachment 418821 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=418821&action=review

>> Source/JavaScriptCore/runtime/AtomicsObject.h:65
>> +JSArrayBufferView* validateTypedArray(JSGlobalObject*, JSValue);
> 
> This seems kind of weird? AtomicsObject.cpp needs to include JSArrayBufferView.h anyway, doesn't it?

Right! I'll remove it.

>> Source/JavaScriptCore/runtime/JSGenericTypedArrayView.h:98
>> +    using Adaptor = PassedAdaptor;
> 
> What's the purpose of this alias?

Because we would like to access ViewClass::Adaptor.

>> JSTests/test262/expectations.yaml:831
>> +  strict mode: 'Test262Error: throws a TypeError getting a value from the detached buffer Expected a TypeError to be thrown but no exception was thrown at all (Testing with BigInt64Array.)'
> 
> Do you want to submit the patch for these or would you prefer that I do it?

I'll quickly do that after landing this patch :)
Comment 14 Yusuke Suzuki 2021-02-01 12:56:58 PST
Committed r272170: <https://trac.webkit.org/changeset/272170>
Comment 15 Radar WebKit Bug Importer 2021-02-01 12:57:20 PST
<rdar://problem/73842238>