This repository was archived by the owner on Jun 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 6666 helpers . push ( h ) ;
6767 }
6868
69+ function ToBigInt64 ( value ) {
70+ let n = BigInt ( value ) ;
71+ let int64bit = n % ( 2n ** 64n ) ;
72+ if ( int64bit > 2n ** 63n ) {
73+ return int64bit - 2n ** 64n ;
74+ }
75+ return int64bit ;
76+ }
77+
6978 // Atomics.waitAsync always returns a promise. Throws standard errors
7079 // for parameter validation. The promise is resolved with a string as from
7180 // Atomics.wait, or, in the case something went completely wrong, it is
7281 // rejected with an error string.
7382
7483 Atomics . waitAsync = function ( ia , index_ , value_ , timeout_ ) {
75- if ( typeof ia != "object" || ! ( ia instanceof Int32Array ) || ! ( ia . buffer instanceof SharedArrayBuffer ) )
76- throw new TypeError ( "Expected shared memory" ) ;
84+ if ( typeof ia != "object" ||
85+ ( ! ( ia instanceof Int32Array ) && ! ( ia instanceof BigInt64Array ) ) ||
86+ ! ( ia . buffer instanceof SharedArrayBuffer ) ) {
87+ throw new TypeError ( "Expected shared memory" ) ;
88+ }
7789
7890 // These conversions only approximate the desired semantics but are
7991 // close enough for the polyfill.
80-
92+ let coersion = ia instanceof BigInt64Array ? ( v => ToBigInt64 ( v ) ) : ( v => v | 0 ) ;
8193 let index = index_ | 0 ;
82- let value = value_ | 0 ;
94+ let value = coersion ( value_ ) ;
8395 let timeout = timeout_ === undefined ? Infinity : + timeout_ ;
8496
8597 // Range checking for the index.
You can’t perform that action at this time.
0 commit comments