summaryrefslogtreecommitdiff
path: root/test/binaryen.js/memory-info.js
blob: 16ec8675319c82d69e05da0b2af9e502dc9d5c98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var module = new binaryen.Module();
assert(module.validate());
console.log(JSON.stringify(module.hasMemory()));

var initial = 1, maximum = 64;

// Not shared
module = new binaryen.Module();
module.setMemory(initial, maximum, '');
assert(module.validate());
console.log(JSON.stringify(module.hasMemory()));
console.log(JSON.stringify(module.getMemoryInfo()));

// Shared
module = new binaryen.Module();
module.setFeatures(binaryen.Features.MVP | binaryen.Features.Atomics);
module.setMemory(initial, maximum, '', [], true);
assert(module.validate());
console.log(JSON.stringify(module.hasMemory()));
console.log(JSON.stringify(module.getMemoryInfo()));

// Imported, not shared
module = new binaryen.Module();
module.addMemoryImport('my_mem', 'env', 'memory', false);
assert(module.validate());
console.log(JSON.stringify(module.hasMemory()));
console.log(JSON.stringify(module.getMemoryInfo()));

// Imported, shared
module = new binaryen.Module();
module.setFeatures(binaryen.Features.MVP | binaryen.Features.Atomics);
module.addMemoryImport('my_mem', 'env', 'memory', true);
assert(module.validate());
console.log(JSON.stringify(module.hasMemory()));
console.log(JSON.stringify(module.getMemoryInfo()));