I actually don't see asm.js work there (it fails on invoke_i being called, likely because of exceptions). However, differences between asm.js and wasm ctor evalling are possible, the wasm ctor evaller happens after asm2wasm, which is after we emterpretify, while in asm.js we do it before we emterpretify.
A better solution might be to not emterpret global ctors, then they can be evalled away. Perhaps we could suggest that in the compiler somehow. On Mon, Aug 7, 2017 at 3:17 AM, liyu <[email protected]> wrote: > Thanks much for the comment, Alon! > We did some more experiments and found that ASM.JS and WASM seem to have > different behaviors: > 1. asm.js "managed to remove 1 ctors" with command "emcc -Oz Source.cpp > -std=c++14 -stdlib=libc++ -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 > --proxy-to-worker --bind -s NO_EXIT_RUNTIME=1 -s TOTAL_MEMORY=369098752 *-s > DISABLE_EXCEPTION_CATCHING=0* -s INLINING_LIMIT=1" > > 2. while WASM can only "remove 1 ctors" without emterpreter enabled. > so does the limitation you mentioned below only exist for WASM? > > Thanks, > Yu > > On Saturday, August 5, 2017 at 1:40:28 AM UTC+8, Alon Zakai wrote: >> >> It looks like the global it complains about is "eb", the emterpreter base >> (where the emterpreted code is placed in linear memory). That isn't known >> at compile time, so the ctor evaller can't precompute it away. In other >> words, this is a limitation of combining the emterpreter, which allocates >> some memory dynamically, and the ctor evaller. >> >> In theory it could be worth looking into making that allocation a static >> one, but I don't know offhand how easy that would be. If someone wants to >> take a look, it is currently generated as something like "var >> eb=getMemory(256736);" >> >> Another option might be to tell the emterpreter to not emterpret the >> method it is trying to use "eb" in (since only emterpreted methods will use >> that global). >> >> On Thu, Aug 3, 2017 at 8:04 PM, liyu <[email protected]> wrote: >> >>> Hi, we are trying the emscripten/incoming branch. the wasm-ctor-eval >>> always returns us "ctor_evaller: not successful". It fails even with the >>> simple test prog (attachment) using this command: >>> "emcc -Oz source.cpp -std=c++14 -stdlib=libc++ -s EMTERPRETIFY=1 -s >>> EMTERPRETIFY_ASYNC=1 --proxy-to-worker --bind -s NO_EXIT_RUNTIME=1 -s >>> TOTAL_MEMORY=369098752 -s DISABLE_EXCEPTION_CATCHING=0 -s INLINING_LIMIT=1 >>> -s WASM=1 -s DETERMINISTIC=1 -s BINARYEN_TRAP_MODE='js' >>> >>> the debug output looks like below: >>> >>> *DEBUG:root:ctor_evaller: 3 ctors, from |__ATINIT__.push({ func: >>> function() { __GLOBAL__I_000101() } }, { func: function() { >>> __GLOBAL__sub_I_source_cpp() } }, { func: function() { >>> __GLOBAL__sub_I_iostream_cpp() } });* >>> >>> *DEBUG:root:ctor_evaller (wasm): trying to eval 3 global constructors* >>> *DEBUG:root:wasm ctor cmd: >>> ['D:/Emscripten/binaryen/master_vs2015_64bit_binaryen\\bin\\wasm-ctor-eval', >>> 'a.out.wasm', '-o', 'a.out.wasm', >>> '--ctors=__GLOBAL__I_000101,__GLOBAL__sub_I_source_cpp,__GLOBAL__sub_I_iostream_cpp']* >>> *DEBUG:root:trying to eval __GLOBAL__I_000101* >>> * ...stopping since could not eval: tried to access a dangerous >>> (import-initialized) global: global$3* >>> *DEBUG:root:ctor_evaller: not successful* >>> >>> is this an unknown issue? or did we miss anything? >>> Thanks in advance >>> >>> -- >>> 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]. For more options, visit https://groups.google.com/d/optout.
