diff options
author | Daniel Wirtz <dcode@dcode.io> | 2017-11-21 21:43:12 +0100 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2017-11-21 12:43:12 -0800 |
commit | eedcc291164a46474116e0e54ede3133214a7621 (patch) | |
tree | 6350e315b74464f48c4f02c6c77a1338b630e144 /src/js/binaryen.js-post.js | |
parent | 07c54750eb626ea7434341e439f6cee75efbf4b5 (diff) | |
download | binaryen-eedcc291164a46474116e0e54ede3133214a7621.tar.gz binaryen-eedcc291164a46474116e0e54ede3133214a7621.tar.bz2 binaryen-eedcc291164a46474116e0e54ede3133214a7621.zip |
Running passes on a single function in binaryen-c/.js (#1295)
* Also other function utilities in C and JS APIs
Diffstat (limited to 'src/js/binaryen.js-post.js')
-rw-r--r-- | src/js/binaryen.js-post.js | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index e6d248715..c6313f2d7 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -1019,6 +1019,16 @@ return Module['_BinaryenAddFunction'](module, strToStack(name), functionType, i32sToStack(varTypes), varTypes.length, body); }); }; + this['getFunction'] = function(name) { + return preserveStack(function() { + return Module['_BinaryenGetFunction'](module, strToStack(name)); + }); + }; + this['removeFunction'] = function(name) { + return preserveStack(function() { + return Module['_BinaryenRemoveFunction'](module, strToStack(name)); + }); + }; this['addGlobal'] = function(name, type, mutable, init) { return preserveStack(function() { return Module['_BinaryenAddGlobal'](module, strToStack(name), type, mutable, init); @@ -1098,13 +1108,25 @@ this['optimize'] = function() { return Module['_BinaryenModuleOptimize'](module); }; + this['optimizeFunction'] = function(func) { + if (typeof func === "string") func = this['getFunction'](func); + return Module['_BinaryenFunctionOptimize'](func, module); + }; this['runPasses'] = function(passes) { return preserveStack(function() { return Module['_BinaryenModuleRunPasses'](module, i32sToStack( passes.map(strToStack) ), passes.length); }); - } + }; + this['runPassesOnFunction'] = function(func, passes) { + if (typeof func === "string") func = this['getFunction'](func); + return preserveStack(function() { + return Module['_BinaryenFunctionRunPasses'](func, module, i32sToStack( + passes.map(strToStack) + ), passes.length); + }); + }; this['autoDrop'] = function() { return Module['_BinaryenModuleAutoDrop'](module); }; @@ -1172,6 +1194,10 @@ return Module['_BinaryenConstGetValueF64'](expr); }; + Module['getFunctionBody'] = function(func) { + return Module['_BinaryenFunctionGetBody'](func); + }; + // emit text of an expression or a module Module['emitText'] = function(expr) { if (typeof expr === 'object') { |