diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-01-23 14:44:46 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-23 14:44:46 -0800 |
commit | 9baf87e8961079da478ec3d3f718d3331963cc77 (patch) | |
tree | 90a91721a6bc195d5c8b2e9ca378f32e59c3c3e3 /src/ir/module-utils.h | |
parent | 155d0b5f42b57100582649dfbdb81806b10579a2 (diff) | |
download | binaryen-9baf87e8961079da478ec3d3f718d3331963cc77.tar.gz binaryen-9baf87e8961079da478ec3d3f718d3331963cc77.tar.bz2 binaryen-9baf87e8961079da478ec3d3f718d3331963cc77.zip |
Show the binary bytes we can remove without each export, in --func-metrics (#1379)
* show the binary bytes we can remove without each export, in --func-metrics
* check start too
Diffstat (limited to 'src/ir/module-utils.h')
-rw-r--r-- | src/ir/module-utils.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h index 0c828f83a..5bcf2ea99 100644 --- a/src/ir/module-utils.h +++ b/src/ir/module-utils.h @@ -18,6 +18,7 @@ #define wasm_ir_module_h #include "wasm.h" +#include "ir/manipulation.h" namespace wasm { @@ -51,6 +52,39 @@ struct BinaryIndexes { } }; +inline void copyModule(Module& in, Module& out) { + // we use names throughout, not raw points, so simple copying is fine + // for everything *but* expressions + for (auto& curr : in.functionTypes) { + out.addFunctionType(new FunctionType(*curr)); + } + for (auto& curr : in.imports) { + out.addImport(new Import(*curr)); + } + for (auto& curr : in.exports) { + out.addExport(new Export(*curr)); + } + for (auto& curr : in.functions) { + auto* func = new Function(*curr); + func->body = ExpressionManipulator::copy(func->body, out); + out.addFunction(func); + } + for (auto& curr : in.globals) { + out.addGlobal(new Global(*curr)); + } + out.table = in.table; + for (auto& segment : out.table.segments) { + segment.offset = ExpressionManipulator::copy(segment.offset, out); + } + out.memory = in.memory; + for (auto& segment : out.memory.segments) { + segment.offset = ExpressionManipulator::copy(segment.offset, out); + } + out.start = in.start; + out.userSections = in.userSections; + out.debugInfoFileNames = in.debugInfoFileNames; +} + } // namespace ModuleUtils } // namespace wasm |