While trying to reproduce asm.js error, I found another problem. SFE
wan't work with -g2 flag, you can reporduce this problem with latest
emscripten:

./emcc -O2 -g2 -s USE_COCOS2D=3 -s ASM_JS=1 --std=c++11
./tests/cocos2d_hello.cpp --preload-file
~/.emscripten_ports/Cocos2d/Cocos2d-version_3_2/samples/Cpp/HelloCpp/Resources@
-o cocos.html

node --max-old-space-size=8192 run_sfe.js --file cocos.js | sponge cocos.js


firefox cocos.html

error:
cocos.html:1249 exception thrown: TypeError: $[(A & 3)] is not a
function,TypeError: $[(A & 3)] is not a function
    at BY 
(file:///home/caiiiycuk/emscripten/sdk/emscripten/cocos2d/cocos.js:10311:2320580)
    at __ZNSt3__26locale8__globalEv
(file:///home/caiiiycuk/emscripten/sdk/emscripten/cocos2d/cocos.js:10311:2159273)
    at __ZNSt3__26localeC2Ev
(file:///home/caiiiycuk/emscripten/sdk/emscripten/cocos2d/cocos.js:10311:2160617)
    at __ZNSt3__28ios_base4initEPv
(file:///home/caiiiycuk/emscripten/sdk/emscripten/cocos2d/cocos.js:10311:2048889)
    at __ZN7cocos2d8BitmapDC12divideStringEP9_TTF_FontPKcii
(file:///home/caiiiycuk/emscripten/sdk/emscripten/cocos2d/cocos.js:10311:350499)
    at __ZN7cocos2d8BitmapDC9getBitmapEPKciiNS_5Image9TextAlignES2_f
(file:///home/caiiiycuk/emscripten/sdk/emscripten/cocos2d/cocos.js:10311:748315)
    at __ZN7cocos2d5Image14initWithStringEPKciiNS0_9TextAlignES2_i
(file:///home/caiiiycuk/emscripten/sdk/emscripten/cocos2d/cocos.js:10311:1308234)
    at __ZN7cocos2d9Texture2D14initWithStringEPKcRKNS_14FontDefinitionE
(file:///home/caiiiycuk/emscripten/sdk/emscripten/cocos2d/cocos.js:10311:1778238)
    at 
__ZN7cocos2d9Texture2D14initWithStringEPKcS2_fRKNS_4SizeENS_14TextHAlignmentENS_14TextVAlignmentE
(file:///home/caiiiycuk/emscripten/sdk/emscripten/cocos2d/cocos.js:10311:1354460)
    at __ZN7cocos2d8LabelTTF13updateTextureEv
(file:///home/caiiiycuk/emscripten/sdk/emscripten/cocos2d/cocos.js:10311:1666246)


Error only occurs in chrome, or is you disable asm.js mode (for
example by debugger)

2017-08-22 23:42 GMT+07:00 arnab choudhury <[email protected]>:
> So - replacing 'Module["asm"] =' with 'var asm =' in build.asm.js followed
> by an attempt to run SFE succeeds. I see the following reduction (around
> 8%).
>
> 08/22/2017  09:15 AM        19,782,571 build.asm.js
> 08/22/2017  09:39 AM        18,225,058 build.asm.reduced.js
>
> I think the core problem right now is that we currently don't support
> running SFE on Emscripten generated JS that was built with the
> --separate-asm flag. I'll look into fixing this today.
>
> Thanks,
> Arnab
>
> On Tuesday, August 22, 2017 at 9:25:32 AM UTC-7, caiiiycuk wrote:
>>
>> Great. I will try to reproduce asm.js bug. Btw, if you build
>> roll-a-ball project in Unity, then output will be in Unity format
>> (also js, but with Unity loader, Unity staff). You can find emscripten
>> output in Project/Library/webgl_cache/linkresult_asm/ folder.
>>
>> 2017-08-22 23:15 GMT+07:00 arnab choudhury <[email protected]>:
>> > Hi caiiycuk
>> >
>> > I'll have an update here shortly. I would love to be able to reproduce
>> > the
>> > non-asm.js bug since we have extensive tests for this at Tableau. I'm
>> > trying
>> > out the roll-a-ball project right now, will get back shortly.
>> >
>> > Regards,
>> > Arnab
>> >
>> > On Tuesday, August 22, 2017 at 3:07:44 AM UTC-7, caiiiycuk wrote:
>> >>
>> >> As I see using SFE breaks asm.js validity? On my another project sfe
>> >> produce js less on 500Kb (from 6.5Mb), but FF says:
>> >> TypeError: asm.js type error: double is not a subtype of intish
>> >>
>> >> 2017-08-22 11:33 GMT+07:00 Александр Гурьянов <[email protected]>:
>> >> > Roll a ball project:
>> >> > https://www.assetstore.unity3d.com/en/#!/content/77198
>> >> >
>> >> > 2017-08-22 11:32 GMT+07:00 Александр Гурьянов <[email protected]>:
>> >> >> Hi. I tried to use SFE on Roll-a-ball demo project, and get same
>> >> >> results. Unity uses --separate-asm flag to build asm.js. Resulting
>> >> >> js
>> >> >> looks like:
>> >> >>
>> >> >> Module["asm"] = (function(global,env,buffer) {
>> >> >> "use asm";var a=new global.Int8Array(buffer);var b=new
>> >> >> global.Int16Array(buffer);...
>> >> >>
>> >> >> I tried to remove wrapping function (Module["asm"] =
>> >> >> (function(global,env,buffer) { ... }), and code looks like:
>> >> >> "use asm";var a=new global.Int8Array(buffer);var b=new
>> >> >> global.Int16Array(buffer);...
>> >> >>
>> >> >> When I run SFE I have another error:
>> >> >>
>> >> >>
>> >> >> /home/caiiiycuk/sdk/Similar-Function-Elimination/node_modules/esprima/esprima.js:5701
>> >> >>             throw e;
>> >> >>             ^
>> >> >> Error: Line 25: Illegal return statement
>> >> >>     at constructError
>> >> >>
>> >> >>
>> >> >> (/home/caiiiycuk/sdk/Similar-Function-Elimination/node_modules/esprima/esprima.js:2406:21)
>> >> >>     at createError
>> >> >>
>> >> >>
>> >> >> (/home/caiiiycuk/sdk/Similar-Function-Elimination/node_modules/esprima/esprima.js:2425:17)
>> >> >>     at tolerateError
>> >> >>
>> >> >>
>> >> >> (/home/caiiiycuk/sdk/Similar-Function-Elimination/node_modules/esprima/esprima.js:2460:17)
>> >> >>     at parseReturnStatement
>> >> >>
>> >> >>
>> >> >> (/home/caiiiycuk/sdk/Similar-Function-Elimination/node_modules/esprima/esprima.js:4533:13)
>> >> >>     at parseStatement
>> >> >>
>> >> >>
>> >> >> (/home/caiiiycuk/sdk/Similar-Function-Elimination/node_modules/esprima/esprima.js:4780:24)
>> >> >>     at parseStatementListItem
>> >> >>
>> >> >>
>> >> >> (/home/caiiiycuk/sdk/Similar-Function-Elimination/node_modules/esprima/esprima.js:3988:16)
>> >> >>     at parseScriptBody
>> >> >>
>> >> >>
>> >> >> (/home/caiiiycuk/sdk/Similar-Function-Elimination/node_modules/esprima/esprima.js:5489:25)
>> >> >>     at parseProgram
>> >> >>
>> >> >>
>> >> >> (/home/caiiiycuk/sdk/Similar-Function-Elimination/node_modules/esprima/esprima.js:5505:16)
>> >> >>     at Object.parse
>> >> >>
>> >> >>
>> >> >> (/home/caiiiycuk/sdk/Similar-Function-Elimination/node_modules/esprima/esprima.js:5689:23)
>> >> >>     at SimilarFunctionEliminator.srcToAst
>> >> >>
>> >> >>
>> >> >> (/home/caiiiycuk/sdk/Similar-Function-Elimination/src/similar_function_eliminator.js:35:20)
>> >> >>
>> >> >>
>> >> >> Maybe I doing something wrong. Can you try? Resulting js is here
>> >> >> (build.asm.js):
>> >> >>
>> >> >>
>> >> >>
>> >> >> https://drive.google.com/file/d/0B28AXjYMDNZscDFlZTdWMGMzQkU/view?usp=sharing
>> >> >>
>> >> >> Thank you!
>> >> >>
>> >> >> 2017-08-22 1:35 GMT+07:00 Александр Гурьянов <[email protected]>:
>> >> >>> I think that error can be reporudced on any Unity project, I will
>> >> >>> check and back) Btw, thanks for nice stuff!
>> >> >>>
>> >> >>> 2017-08-22 1:27 GMT+07:00 arnab choudhury <[email protected]>:
>> >> >>>> Thanks Alon :).
>> >> >>>>
>> >> >>>> Caiiycuk, is the codebase you are trying to run SFE on available
>> >> >>>> publicly?
>> >> >>>> Can you post the github link here if so? If not, take a look at
>> >> >>>> the
>> >> >>>> generated JS on which you are going to run SFE on. Make sure that
>> >> >>>> there is a
>> >> >>>> top level global variable called asm. If the asm.js is wrapped,
>> >> >>>> then
>> >> >>>> you
>> >> >>>> might have to save off the asm.js (the part of the code that
>> >> >>>> contains
>> >> >>>> a top
>> >> >>>> level variable called asm) to a separate file and try running SFE
>> >> >>>> on
>> >> >>>> that to
>> >> >>>> see the potential size reduction.
>> >> >>>>
>> >> >>>> Regards,
>> >> >>>> Arnab
>> >> >>>>
>> >> >>>> On Monday, August 21, 2017 at 10:47:22 AM UTC-7, Alon Zakai wrote:
>> >> >>>>>
>> >> >>>>> Very interesting stuff here! :)
>> >> >>>>>
>> >> >>>>> I opened this issue for implementation in Binaryen:
>> >> >>>>> https://github.com/WebAssembly/binaryen/issues/1142
>> >> >>>>>
>> >> >>>>> On Fri, Aug 18, 2017 at 8:24 AM, arnab choudhury
>> >> >>>>> <[email protected]>
>> >> >>>>> wrote:
>> >> >>>>>>
>> >> >>>>>> Hello Emscripten-Discuss
>> >> >>>>>>
>> >> >>>>>> I just wanted to bring folks' attention to a new post-build
>> >> >>>>>> optimization
>> >> >>>>>> pass for Emscripten generated asm.js called Similar Function
>> >> >>>>>> Elimination
>> >> >>>>>> (SFE) that Tableau recently open sourced. I discussed with Alon,
>> >> >>>>>> and our
>> >> >>>>>> thinking is that we will be adding this pass to Binaryen's web
>> >> >>>>>> assembly
>> >> >>>>>> generator. Given that everyone is moving to Web Assembly, we are
>> >> >>>>>> thinking we
>> >> >>>>>> may not add this pass back to Emscripten. However, that being
>> >> >>>>>> said,
>> >> >>>>>> the
>> >> >>>>>> Emscripten community should feel free to use Similar Function
>> >> >>>>>> Elimination on
>> >> >>>>>> Emscripten generated asm.js if you need the additional size
>> >> >>>>>> reduction.
>> >> >>>>>>
>> >> >>>>>> https://github.com/achoudhury85/Similar-Function-Elimination
>> >> >>>>>>
>> >> >>>>>> At Tableau, we have observed up to 20% code size reduction when
>> >> >>>>>> using SFE
>> >> >>>>>> on template heavy codebases.
>> >> >>>>>>
>> >> >>>>>> Regards,
>> >> >>>>>> 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].
>> > 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.

Reply via email to