Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/src/runtime_asan.js
4128 views
1
/**
2
* @license
3
* Copyright 2019 The Emscripten Authors
4
* SPDX-License-Identifier: MIT
5
*/
6
7
#if !USE_ASAN
8
#error "should only be inclded in USE_ASAN mode"
9
#endif
10
11
// C versions of asan_js_{load|store} will be used from compiled code, which have
12
// ASan instrumentation on them. However, until the wasm module is ready, we
13
// must access things directly.
14
15
function _asan_js_check_index(arr, index, asanFn) {
16
#if EXIT_RUNTIME
17
if (runtimeInitialized && !runtimeExited) {
18
#else
19
if (runtimeInitialized) {
20
#endif
21
const elemSize = arr.BYTES_PER_ELEMENT;
22
asanFn(index * elemSize, elemSize);
23
}
24
}
25
26
function _asan_js_load(arr, index) {
27
_asan_js_check_index(arr, index, ___asan_loadN);
28
return arr[index];
29
}
30
31
function _asan_js_store(arr, index, value) {
32
_asan_js_check_index(arr, index, ___asan_storeN);
33
return arr[index] = value;
34
}
35
36