emscripten-core/emscripten

Optimizing output .js size: using createExportWrapper with no assertions

Open

#14,695 创建于 2021年7月20日

在 GitHub 查看
 (12 评论) (1 反应) (1 负责人)C++ (3,519 fork)batch import
help wanted

仓库指标

Star
 (27,361 star)
PR 合并指标
 (平均合并 19天 10小时) (30 天内合并 147 个 PR)

描述

While looking at produced .js files for Pyodide (pyodide.asm.js, 1.78 MB total, 293kB compressed) a lot of the size seems to be due to this function definition for each symbol, https://github.com/emscripten-core/emscripten/blob/e77adf8a3a79e79b666dce6d7ad0d6d3b9e94b20/emscripten.py#L671-L674 in part because the mangled name can be quite long and it's repeated 4 times there.

Would it make sense to use an equivalent of createExportWrapper instead as done a few lines above? https://github.com/emscripten-core/emscripten/blob/e77adf8a3a79e79b666dce6d7ad0d6d3b9e94b20/emscripten.py#L659-L661

or even

 /** @type {function(...*):?} */ 
 var %(mangled)s = createExportWrapper("%(name)s", Module); 
 ''' % {'mangled': mangled, 'name': name}) 

where createExportWrapper is currently defined only when assertions = true. I'm not saying to use createExportWrapper exactly but an equivalent simpler function with no assertions. Unless there is a reason the current solution is preferable? Thanks!

贡献者指南