diff options
Diffstat (limited to 'src/shell_sharedlib.js')
-rw-r--r-- | src/shell_sharedlib.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/shell_sharedlib.js b/src/shell_sharedlib.js index 1d34c73e..c070c617 100644 --- a/src/shell_sharedlib.js +++ b/src/shell_sharedlib.js @@ -1,8 +1,24 @@ // Capture the output of this into a variable, if you want -(function(FUNCTION_TABLE_OFFSET, globalScope) { +(function(FUNCTION_TABLE_OFFSET, parentModule) { var Module = {}; var args = []; Module.arguments = []; + Module.print = parentModule.print; + Module.printErr = parentModule.printErr; + + Module.cleanups = []; + +#if ASM_JS + var H_BASE = 0; + // Each module has its own stack + var STACKTOP = parentModule['_malloc'](TOTAL_STACK); + assert(STACKTOP % 8 == 0); + var STACK_MAX = STACKTOP + TOTAL_STACK; + Module.cleanups.push(function() { + parentModule['_free'](STACKTOP); // XXX ensure exported + parentModule['_free'](H_BASE); + }); +#endif {{BODY}} @@ -10,3 +26,4 @@ return Module; }); + |