All variables that are local to the ASM JS scope become contained within the asmJSPrivateState dictionary variable. So, for the STACKTOP variable (and all other ASM JS global variables), we modify the AST so that all references to it are replaced with asmJSPrivateState.STACKTOP - that does the trick. The main HTML file includes all the chunked JS files and each one can modify asmJSPrivateState.STACKTOP as appropriate - and the other chunks will see the effects of that change.
Hope this helps - although I had written this tool as a standalone outside of the emscripten codebase, I can create a pull request with it integrated into the emscripten codebase if there's enough interest. On Monday, January 4, 2016 at 11:00:00 AM UTC-8, Alon Zakai wrote: > > Interesting! > > What happens in practice with e.g. the STACKTOP global variable which is > in the asm.js scope? How is it shared and updated between separate > functions? > > On Mon, Dec 28, 2015 at 12:48 PM, arnab choudhury <[email protected] > <javascript:>> wrote: > >> FYI - In order to work around the problem, I went ahead and wrote a >> python script that mimic'ed Emscripten's JS optimizer python file to split >> up the large ASM JS file (using uglify JS) into a number of smaller JS >> files - all configured via a set size (I used 512K). The script would also >> modify the Emscripten generated HTML to include all the smaller JS files >> instead of the one large file. Its come in super handy to debug large JS >> files. If there's enough interest to port back to Emscripten, I can make >> this code available. If this sounds interesting, please read the attached >> doc that talks about it in greater detail (unfortunately, its too long to >> paste into this thread). >> >> On Monday, December 14, 2015 at 8:55:50 AM UTC-8, jj wrote: >>> >>> We have two items in the Firefox issue tracker regarding debugging large >>> files: >>> >>> https://bugzilla.mozilla.org/show_bug.cgi?id=1158098 - Improve debugger >>> to navigate and search large UE4 StrategyGame JavaScript file. >>> https://bugzilla.mozilla.org/show_bug.cgi?id=1224726 - High memory >>> consumption when opening and searching a large Javascript file in debugger. >>> >>> These are in the radar for 2016, so we are hoping to improve things >>> greatly here. >>> >>> 2015-12-04 23:16 GMT+02:00 Alon Zakai <[email protected]>: >>> >>>> Yes, this is a known issue. There is progress on the browser side to >>>> more efficiently handle such large programs, but no browser does this well >>>> yet. >>>> >>>> Emscripten supports dynamic linking, >>>> >>>> https://github.com/kripken/emscripten/wiki/Linking >>>> >>>> This can be a solution for this problem, by splitting things up into >>>> smaller files. >>>> >>>> In practice, personally, I tend to use print debugging and I open the >>>> file in a text editor on the side that can handle massive text files. >>>> >>>> On Fri, Dec 4, 2015 at 12:02 PM, arnab choudhury <[email protected]> >>>> wrote: >>>> >>>>> Hey all >>>>> >>>>> I'm using Emscripten to convert a decent sized C++ codebase to >>>>> Javascript. As part of this process, I'm finding that debugging the >>>>> unoptimized generated JS can be quite painful. Specifically, some JS >>>>> files >>>>> can be up to 1 million lines long and this completely breaks my browser's >>>>> node debugger (via node-inspector). Google's v8 debugger (via node debug) >>>>> also has a hard time stepping through code. My only debugging technique >>>>> that works currently is to enter print statements, and debug and build >>>>> iteratively. >>>>> >>>>> I saw some threads on github about emscripten having the ability to >>>>> split up the generated JS files into multiple files. However, the latest >>>>> version of emscripten doesn't seem to support this. Have others run into >>>>> this issue? Are there any existing solutions for this problem? >>>>> >>>>> Thanks, >>>>> Arnab >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "emscripten-discuss" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to [email protected]. >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "emscripten-discuss" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "emscripten-discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
