summaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorJackson Gardner <eyebrowsoffire@gmail.com>2022-05-24 09:59:47 -0700
committerGitHub <noreply@github.com>2022-05-24 09:59:47 -0700
commit721e8ffb975a6e68a56287cd46ecc19e107211c6 (patch)
tree021219639b5c4b80c235cce42c79902c40fa4794 /src/js
parenta78d0e44cbcc72682ab9c45dec76d4b1c52588c9 (diff)
downloadbinaryen-721e8ffb975a6e68a56287cd46ecc19e107211c6.tar.gz
binaryen-721e8ffb975a6e68a56287cd46ecc19e107211c6.tar.bz2
binaryen-721e8ffb975a6e68a56287cd46ecc19e107211c6.zip
Add C and JS API functions for accessing memory info (#4682)
Based on #3573 plus minor fixes
Diffstat (limited to 'src/js')
-rw-r--r--src/js/binaryen.js-post.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js
index 28f5b6258..b6ea7dee1 100644
--- a/src/js/binaryen.js-post.js
+++ b/src/js/binaryen.js-post.js
@@ -2500,9 +2500,24 @@ function wrapModule(module, self = {}) {
);
});
};
+ self['hasMemory'] = function() {
+ return Boolean(Module['_BinaryenHasMemory'](module));
+ };
+ self['getMemoryInfo'] = function() {
+ var memoryInfo = {
+ 'module': UTF8ToString(Module['_BinaryenMemoryImportGetModule'](module)),
+ 'base': UTF8ToString(Module['_BinaryenMemoryImportGetBase'](module)),
+ 'initial': Module['_BinaryenMemoryGetInitial'](module),
+ 'shared': Boolean(Module['_BinaryenMemoryIsShared'](module))
+ };
+ if (Module['_BinaryenMemoryHasMax'](module)) {
+ memoryInfo['max'] = Module['_BinaryenMemoryGetMax'](module);
+ }
+ return memoryInfo;
+ };
self['getNumMemorySegments'] = function() {
return Module['_BinaryenGetNumMemorySegments'](module);
- }
+ };
self['getMemorySegmentInfoByIndex'] = function(id) {
return {
'offset': Module['_BinaryenGetMemorySegmentByteOffset'](module, id),
@@ -2517,7 +2532,7 @@ function wrapModule(module, self = {}) {
})(),
'passive': Boolean(Module['_BinaryenGetMemorySegmentPassive'](module, id))
};
- }
+ };
self['setStart'] = function(start) {
return Module['_BinaryenSetStart'](module, start);
};