|
8 | 8 | #error "should only be inclded in USE_ASAN mode"
|
9 | 9 | #endif
|
10 | 10 |
|
11 |
| -// C versions of asan_js_{load|store}_* will be used from compiled code, which have |
| 11 | +// C versions of asan_js_{load|store} will be used from compiled code, which have |
12 | 12 | // ASan instrumentation on them. However, until the wasm module is ready, we
|
13 | 13 | // must access things directly.
|
14 | 14 |
|
15 |
| -/** @suppress{duplicate} */ |
16 |
| -function _asan_js_load_1(ptr) { |
17 |
| - if (runtimeInitialized) return __asan_c_load_1(ptr); |
18 |
| - return HEAP8[ptr]; |
19 |
| -} |
20 |
| -/** @suppress{duplicate} */ |
21 |
| -function _asan_js_load_1u(ptr) { |
22 |
| - if (runtimeInitialized) return __asan_c_load_1u(ptr); |
23 |
| - return HEAPU8[ptr]; |
24 |
| -} |
25 |
| -/** @suppress{duplicate} */ |
26 |
| -function _asan_js_load_2(ptr) { |
27 |
| - if (runtimeInitialized) return __asan_c_load_2(ptr); |
28 |
| - return HEAP16[ptr]; |
29 |
| -} |
30 |
| -/** @suppress{duplicate} */ |
31 |
| -function _asan_js_load_2u(ptr) { |
32 |
| - if (runtimeInitialized) return __asan_c_load_2u(ptr); |
33 |
| - return HEAPU16[ptr]; |
34 |
| -} |
35 |
| -/** @suppress{duplicate} */ |
36 |
| -function _asan_js_load_4(ptr) { |
37 |
| - if (runtimeInitialized) return __asan_c_load_4(ptr); |
38 |
| - return HEAP32[ptr]; |
39 |
| -} |
40 |
| -/** @suppress{duplicate} */ |
41 |
| -function _asan_js_load_4u(ptr) { |
42 |
| - if (runtimeInitialized) return __asan_c_load_4u(ptr) >>> 0; |
43 |
| - return HEAPU32[ptr]; |
44 |
| -} |
45 |
| -/** @suppress{duplicate} */ |
46 |
| -function _asan_js_load_8(ptr) { |
47 |
| - if (runtimeInitialized) return __asan_c_load_8(ptr); |
48 |
| - return HEAP64[ptr]; |
49 |
| -} |
50 |
| -/** @suppress{duplicate} */ |
51 |
| -function _asan_js_load_8u(ptr) { |
52 |
| - if (runtimeInitialized) return BigInt.asUintN(64, __asan_c_load_8u(ptr)); |
53 |
| - return HEAPU64[ptr]; |
54 |
| -} |
55 |
| -/** @suppress{duplicate} */ |
56 |
| -function _asan_js_load_f(ptr) { |
57 |
| - if (runtimeInitialized) return __asan_c_load_f(ptr); |
58 |
| - return HEAPF32[ptr]; |
59 |
| -} |
60 |
| -/** @suppress{duplicate} */ |
61 |
| -function _asan_js_load_d(ptr) { |
62 |
| - if (runtimeInitialized) return __asan_c_load_d(ptr); |
63 |
| - return HEAPF64[ptr]; |
| 15 | +function _asan_js_load(arr, index) { |
| 16 | + if (runtimeInitialized) { |
| 17 | + const elemSize = arr.BYTES_PER_ELEMENT; |
| 18 | + ___asan_loadN(index * elemSize, elemSize); |
| 19 | + } |
| 20 | + return arr[index]; |
64 | 21 | }
|
65 | 22 |
|
66 |
| -/** @suppress{duplicate} */ |
67 |
| -function _asan_js_store_1(ptr, val) { |
68 |
| - if (runtimeInitialized) return __asan_c_store_1(ptr, val); |
69 |
| - return HEAP8[ptr] = val; |
70 |
| -} |
71 |
| -/** @suppress{duplicate} */ |
72 |
| -function _asan_js_store_1u(ptr, val) { |
73 |
| - if (runtimeInitialized) return __asan_c_store_1u(ptr, val); |
74 |
| - return HEAPU8[ptr] = val; |
75 |
| -} |
76 |
| -/** @suppress{duplicate} */ |
77 |
| -function _asan_js_store_2(ptr, val) { |
78 |
| - if (runtimeInitialized) return __asan_c_store_2(ptr, val); |
79 |
| - return HEAP16[ptr] = val; |
80 |
| -} |
81 |
| -/** @suppress{duplicate} */ |
82 |
| -function _asan_js_store_2u(ptr, val) { |
83 |
| - if (runtimeInitialized) return __asan_c_store_2u(ptr, val); |
84 |
| - return HEAPU16[ptr] = val; |
85 |
| -} |
86 |
| -/** @suppress{duplicate} */ |
87 |
| -function _asan_js_store_4(ptr, val) { |
88 |
| - if (runtimeInitialized) return __asan_c_store_4(ptr, val); |
89 |
| - return HEAP32[ptr] = val; |
90 |
| -} |
91 |
| -/** @suppress{duplicate} */ |
92 |
| -function _asan_js_store_4u(ptr, val) { |
93 |
| - if (runtimeInitialized) return __asan_c_store_4u(ptr, val) >>> 0; |
94 |
| - return HEAPU32[ptr] = val; |
95 |
| -} |
96 |
| -/** @suppress{duplicate} */ |
97 |
| -function _asan_js_store_8(ptr, val) { |
98 |
| - if (runtimeInitialized) return __asan_c_store_8(ptr, val); |
99 |
| - return HEAP64[ptr] = val; |
100 |
| -} |
101 |
| -/** @suppress{duplicate} */ |
102 |
| -function _asan_js_store_8u(ptr, val) { |
| 23 | +function _asan_js_store(arr, index, value) { |
103 | 24 | if (runtimeInitialized) {
|
104 |
| - __asan_c_store_8u(ptr, val); |
105 |
| - return val; |
| 25 | + const elemSize = arr.BYTES_PER_ELEMENT; |
| 26 | + ___asan_storeN(index * elemSize, elemSize); |
106 | 27 | }
|
107 |
| - return HEAPU64[ptr] = val; |
108 |
| -} |
109 |
| -/** @suppress{duplicate} */ |
110 |
| -function _asan_js_store_f(ptr, val) { |
111 |
| - if (runtimeInitialized) return __asan_c_store_f(ptr, val); |
112 |
| - return HEAPF32[ptr] = val; |
113 |
| -} |
114 |
| -/** @suppress{duplicate} */ |
115 |
| -function _asan_js_store_d(ptr, val) { |
116 |
| - if (runtimeInitialized) return __asan_c_store_d(ptr, val); |
117 |
| - return HEAPF64[ptr] = val; |
| 28 | + return arr[index] = value; |
118 | 29 | }
|
0 commit comments