MCPcopy Create free account
hub / github.com/nodejs/node / Module

Function Module

deps/v8/test/mjsunit/asm/atomics-exchange.js:5–60  ·  view source on GitHub ↗
(stdlib, foreign, heap, offset)

Source from the content-addressed store, hash-verified

3// found in the LICENSE file.
4
5function Module(stdlib, foreign, heap, offset) {
6 "use asm";
7 var MEM8 = new stdlib.Int8Array(heap, offset);
8 var MEM16 = new stdlib.Int16Array(heap, offset);
9 var MEM32 = new stdlib.Int32Array(heap, offset);
10 var MEMU8 = new stdlib.Uint8Array(heap, offset);
11 var MEMU16 = new stdlib.Uint16Array(heap, offset);
12 var MEMU32 = new stdlib.Uint32Array(heap, offset);
13 var exchange = stdlib.Atomics.exchange;
14 var fround = stdlib.Math.fround;
15
16 function exchangei8(i, x) {
17 i = i | 0;
18 x = x | 0;
19 return exchange(MEM8, i, x)|0;
20 }
21
22 function exchangei16(i, x) {
23 i = i | 0;
24 x = x | 0;
25 return exchange(MEM16, i, x)|0;
26 }
27
28 function exchangei32(i, x) {
29 i = i | 0;
30 x = x | 0;
31 return exchange(MEM32, i, x)|0;
32 }
33
34 function exchangeu8(i, x) {
35 i = i | 0;
36 x = x >>> 0;
37 return exchange(MEMU8, i, x)>>>0;
38 }
39
40 function exchangeu16(i, x) {
41 i = i | 0;
42 x = x >>> 0;
43 return exchange(MEMU16, i, x)>>>0;
44 }
45
46 function exchangeu32(i, x) {
47 i = i | 0;
48 x = x >>> 0;
49 return exchange(MEMU32, i, x)>>>0;
50 }
51
52 return {
53 exchangei8: exchangei8,
54 exchangei16: exchangei16,
55 exchangei32: exchangei32,
56 exchangeu8: exchangeu8,
57 exchangeu16: exchangeu16,
58 exchangeu32: exchangeu32,
59 };
60}
61
62var sab = new SharedArrayBuffer(16);

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected