Re: Similar Function Elimination

2017-08-23 Thread Александр Гурьянов
> RollABall
Sorry man! Looks like using sed s'/Module\["asm"\]/var asm/' and then
run SFE will produce error. But, if I simply run SFE then it works.
Great!))
Solved!

> non-valid asm.js

No it's other big project. I can confirm that Cocos2d works fine.
Maybe I can share resulting js of this project, but I can't share
source because of NDA. Would you think can it helps?
Btw, if I found test case how to reporduce then I create issue on github.

Thanks!


2017-08-23 22:39 GMT+07:00 arnab choudhury :
> BTW for the RollABall build.asm.js, you don't have to modify the asm.js file
> any more before running SFE after taking commit
> 8e62700a102fe12a6b1ff73934e21ae127e7f6ac, just wanted to call this out
> explicitly. You should be able to directly run run_sfe.js on the file.
>
>
> On Wednesday, August 23, 2017 at 8:31:44 AM UTC-7, arnab choudhury wrote:
>>
>> Hi Caiiycuk
>>
>> Given that you are still reproing your bug on the RollABall project, can
>> you tell me what your development configuration is (what OS are you using,
>> what version of nodejs are you using, etc.)? I just double checked that I
>> could successfully reduce build.asm.js from your zip file on Google Drive
>> using the latest run_sfe.js. Can you double check that you have commit ID
>> 8e62700a102fe12a6b1ff73934e21ae127e7f6ac in your git log?
>>
>> Regarding the errors that you are seeing with non-valid asm.js, just to
>> confirm, this is on Cocos2d, correct? I did check that we were generating
>> valid asm.js, but I didn't try running the game (I had some missing pngs and
>> saw a runtime exception being thrown - but it was the same before and after
>> running SFE). I'll make sure I can run it after running SFE.
>>
>> Also, I think if you see more issues, it may be better to track them using
>> the GitHub issue tracker for SFE:
>> https://github.com/achoudhury85/Similar-Function-Elimination/issues.
>>
>> Regards,
>> Arnab
>>
>> On Tuesday, August 22, 2017 at 11:43:09 PM UTC-7, caiiiycuk wrote:
>>>
>>> TypeError: asm.js type error: double is not a subtype of intish
>>>
>>> 2017-08-23 13:42 GMT+07:00 Александр Гурьянов :
>>> > Sorry, missed error line from prev message:
>>> > TypeError: asm.js type error: double is not a subtype of intish
>>> >
>>> > 2017-08-23 13:42 GMT+07:00 Александр Гурьянов :
>>> >> Without -g2 I have this error:
>>> >> g[a+4>>2]=-$|0;
>>> >>
>>> >> In function:
>>> >> function Bg(a,b,$){a=a|0;b=b|0;$=+$;g[a>>2]=0.0;g[a+4>>2]=-$|0;return}
>>> >>
>>> >> And SFE on roll-a-ball project still does not work with same error. I
>>> >> start believe that I doing something wrong in build steps...
>>> >>
>>> >> P.S. My projects have a lot of undefined symbols (but they does not
>>> >> used), can this be a problem?
>>> >>
>>> >>
>>> >>
>>> >> 2017-08-23 13:34 GMT+07:00 Александр Гурьянов :
>>> >>> Hi. After your commit -g2 error gone. But my project does not work. I
>>> >>> see black screen (no errors, just black screen). And this error:
>>> >>>
>>> >>> TypeError: asm.js type error: void incompatible with previous return
>>> >>> of type f64
>>> >>>
>>> >>> If I remove -g2 game works (but asm.js not). Btw, I trying to find
>>> >>> how
>>> >>> to reporduce.
>>> >>>
>>> >>> The code for "asm.js type error: void incompatible with previous
>>> >>> return of type f64" is:
>>> >>>
>>> >>> function _roundf(d1){d1=+d1;(Jl(d1))}
>>> >>>
>>> >>> grep for _roundf in js:
>>> 2]|0)+284>>2]|0;d37=+_roundf(+d28);d42=+_roundf(+
>>> 2]|0)+284>>2]|0;d28=+_roundf(+d44);d42=+_roundf(+
>>> 2]|0)+284>>2]|0;d50=+_roundf(+d37);FUNCTION_TABLE
>>> 2]|0)+284>>2]|0;d50=+_roundf(+(d37+d28));FUNCTION
>>> >>> 1=HEAP32[i8>>2]|0;d2=+_roundf(+ +HEAPF32[i1+20>>2]
>>> >>> HEAP32[i10>>2]|0;d13=+_roundf(+(d2*+HEAPF32[i1+20>
>>> >>> AP32[i1+8>>2]|0;i9=~~+_roundf(+(+(i7|0)*1.5/+HEAPF
>>> 2]|0;HEAPF32[i6>>2]=+_roundf(+d7);HEAPF32[i8>>2]=
>>> >>> =i1|0;var i2=0;i2=~~-+_roundf(+(+HEAPF64[i1+224>>3
>>> >>>  DO(i1,24)|0}function _roundf(d1){d1=+d1;(Jl(d1))}
>>> >>> serialization_pb_cpp, _roundf: _roundf, __GLOBAL__
>>> >>>
>>> >>> 2017-08-23 5:00 GMT+07:00 arnab choudhury :
>>>  Hello caiiycuk - the latest commit to the master branch fixes this
>>>  issue.
>>>  Please let me know if you see any issues. Thanks for the due
>>>  diligence!
>>> 
>>>  Regards,
>>>  Arnab
>>> 
>>> 
>>>  On Tuesday, August 22, 2017 at 12:36:23 PM UTC-7, arnab choudhury
>>>  wrote:
>>> >
>>> > Thanks for catching this caiiycuk - I can repro and will have a fix
>>> > out
>>> > shortly. Looks like a name-clash bug in the minified name generator
>>> > SFE
>>> > uses.
>>> >
>>> > On Tuesday, August 22, 2017 at 10:17:15 AM UTC-7, caiiiycuk wrote:
>>> >>
>>> >> While trying to reproduce asm.js error, I found another problem.
>>> >> SFE
>>> >> wan't work with -g2 flag, you can reporduce this problem with

Re: Similar Function Elimination

2017-08-23 Thread arnab choudhury
BTW for the RollABall build.asm.js, you don't have to modify the asm.js 
file any more before running SFE after taking commit 
8e62700a102fe12a6b1ff73934e21ae127e7f6ac, just wanted to call this out 
explicitly. You should be able to directly run run_sfe.js on the file.

On Wednesday, August 23, 2017 at 8:31:44 AM UTC-7, arnab choudhury wrote:
>
> Hi Caiiycuk
>
> Given that you are still reproing your bug on the RollABall project, can 
> you tell me what your development configuration is (what OS are you using, 
> what version of nodejs are you using, etc.)? I just double checked that I 
> could successfully reduce build.asm.js from your zip file on Google Drive 
> using the latest run_sfe.js. Can you double check that you have commit 
> ID 8e62700a102fe12a6b1ff73934e21ae127e7f6ac in your git log? 
>
> Regarding the errors that you are seeing with non-valid asm.js, just to 
> confirm, this is on Cocos2d, correct? I did check that we were generating 
> valid asm.js, but I didn't try running the game (I had some missing pngs 
> and saw a runtime exception being thrown - but it was the same before and 
> after running SFE). I'll make sure I can run it after running SFE.
>
> Also, I think if you see more issues, it may be better to track them using 
> the GitHub issue tracker for SFE: 
> https://github.com/achoudhury85/Similar-Function-Elimination/issues.
>
> Regards,
> Arnab
>
> On Tuesday, August 22, 2017 at 11:43:09 PM UTC-7, caiiiycuk wrote:
>>
>> TypeError: asm.js type error: double is not a subtype of intish 
>>
>> 2017-08-23 13:42 GMT+07:00 Александр Гурьянов : 
>> > Sorry, missed error line from prev message: 
>> > TypeError: asm.js type error: double is not a subtype of intish 
>> > 
>> > 2017-08-23 13:42 GMT+07:00 Александр Гурьянов : 
>> >> Without -g2 I have this error: 
>> >> g[a+4>>2]=-$|0; 
>> >> 
>> >> In function: 
>> >> function Bg(a,b,$){a=a|0;b=b|0;$=+$;g[a>>2]=0.0;g[a+4>>2]=-$|0;return} 
>> >> 
>> >> And SFE on roll-a-ball project still does not work with same error. I 
>> >> start believe that I doing something wrong in build steps... 
>> >> 
>> >> P.S. My projects have a lot of undefined symbols (but they does not 
>> >> used), can this be a problem? 
>> >> 
>> >> 
>> >> 
>> >> 2017-08-23 13:34 GMT+07:00 Александр Гурьянов : 
>> >>> Hi. After your commit -g2 error gone. But my project does not work. I 
>> >>> see black screen (no errors, just black screen). And this error: 
>> >>> 
>> >>> TypeError: asm.js type error: void incompatible with previous return 
>> of type f64 
>> >>> 
>> >>> If I remove -g2 game works (but asm.js not). Btw, I trying to find 
>> how 
>> >>> to reporduce. 
>> >>> 
>> >>> The code for "asm.js type error: void incompatible with previous 
>> >>> return of type f64" is: 
>> >>> 
>> >>> function _roundf(d1){d1=+d1;(Jl(d1))} 
>> >>> 
>> >>> grep for _roundf in js: 
>> 2]|0)+284>>2]|0;d37=+_roundf(+d28);d42=+_roundf(+ 
>> 2]|0)+284>>2]|0;d28=+_roundf(+d44);d42=+_roundf(+ 
>> 2]|0)+284>>2]|0;d50=+_roundf(+d37);FUNCTION_TABLE 
>> 2]|0)+284>>2]|0;d50=+_roundf(+(d37+d28));FUNCTION 
>> >>> 1=HEAP32[i8>>2]|0;d2=+_roundf(+ +HEAPF32[i1+20>>2] 
>> >>> HEAP32[i10>>2]|0;d13=+_roundf(+(d2*+HEAPF32[i1+20> 
>> >>> AP32[i1+8>>2]|0;i9=~~+_roundf(+(+(i7|0)*1.5/+HEAPF 
>> 2]|0;HEAPF32[i6>>2]=+_roundf(+d7);HEAPF32[i8>>2]= 
>> >>> =i1|0;var i2=0;i2=~~-+_roundf(+(+HEAPF64[i1+224>>3 
>> >>>  DO(i1,24)|0}function _roundf(d1){d1=+d1;(Jl(d1))} 
>> >>> serialization_pb_cpp, _roundf: _roundf, __GLOBAL__ 
>> >>> 
>> >>> 2017-08-23 5:00 GMT+07:00 arnab choudhury : 
>>  Hello caiiycuk - the latest commit to the master branch fixes this 
>> issue. 
>>  Please let me know if you see any issues. Thanks for the due 
>> diligence! 
>>  
>>  Regards, 
>>  Arnab 
>>  
>>  
>>  On Tuesday, August 22, 2017 at 12:36:23 PM UTC-7, arnab choudhury 
>> wrote: 
>> > 
>> > Thanks for catching this caiiycuk - I can repro and will have a fix 
>> out 
>> > shortly. Looks like a name-clash bug in the minified name generator 
>> SFE 
>> > uses. 
>> > 
>> > On Tuesday, August 22, 2017 at 10:17:15 AM UTC-7, caiiiycuk wrote: 
>> >> 
>> >> 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 
>> >> 

Re: Similar Function Elimination

2017-08-23 Thread Александр Гурьянов
TypeError: asm.js type error: double is not a subtype of intish

2017-08-23 13:42 GMT+07:00 Александр Гурьянов :
> Sorry, missed error line from prev message:
> TypeError: asm.js type error: double is not a subtype of intish
>
> 2017-08-23 13:42 GMT+07:00 Александр Гурьянов :
>> Without -g2 I have this error:
>> g[a+4>>2]=-$|0;
>>
>> In function:
>> function Bg(a,b,$){a=a|0;b=b|0;$=+$;g[a>>2]=0.0;g[a+4>>2]=-$|0;return}
>>
>> And SFE on roll-a-ball project still does not work with same error. I
>> start believe that I doing something wrong in build steps...
>>
>> P.S. My projects have a lot of undefined symbols (but they does not
>> used), can this be a problem?
>>
>>
>>
>> 2017-08-23 13:34 GMT+07:00 Александр Гурьянов :
>>> Hi. After your commit -g2 error gone. But my project does not work. I
>>> see black screen (no errors, just black screen). And this error:
>>>
>>> TypeError: asm.js type error: void incompatible with previous return of 
>>> type f64
>>>
>>> If I remove -g2 game works (but asm.js not). Btw, I trying to find how
>>> to reporduce.
>>>
>>> The code for "asm.js type error: void incompatible with previous
>>> return of type f64" is:
>>>
>>> function _roundf(d1){d1=+d1;(Jl(d1))}
>>>
>>> grep for _roundf in js:
2]|0)+284>>2]|0;d37=+_roundf(+d28);d42=+_roundf(+
2]|0)+284>>2]|0;d28=+_roundf(+d44);d42=+_roundf(+
2]|0)+284>>2]|0;d50=+_roundf(+d37);FUNCTION_TABLE
2]|0)+284>>2]|0;d50=+_roundf(+(d37+d28));FUNCTION
>>> 1=HEAP32[i8>>2]|0;d2=+_roundf(+ +HEAPF32[i1+20>>2]
>>> HEAP32[i10>>2]|0;d13=+_roundf(+(d2*+HEAPF32[i1+20>
>>> AP32[i1+8>>2]|0;i9=~~+_roundf(+(+(i7|0)*1.5/+HEAPF
2]|0;HEAPF32[i6>>2]=+_roundf(+d7);HEAPF32[i8>>2]=
>>> =i1|0;var i2=0;i2=~~-+_roundf(+(+HEAPF64[i1+224>>3
>>>  DO(i1,24)|0}function _roundf(d1){d1=+d1;(Jl(d1))}
>>> serialization_pb_cpp, _roundf: _roundf, __GLOBAL__
>>>
>>> 2017-08-23 5:00 GMT+07:00 arnab choudhury :
 Hello caiiycuk - the latest commit to the master branch fixes this issue.
 Please let me know if you see any issues. Thanks for the due diligence!

 Regards,
 Arnab


 On Tuesday, August 22, 2017 at 12:36:23 PM UTC-7, arnab choudhury wrote:
>
> Thanks for catching this caiiycuk - I can repro and will have a fix out
> shortly. Looks like a name-clash bug in the minified name generator SFE
> uses.
>
> On Tuesday, August 22, 2017 at 10:17:15 AM UTC-7, caiiiycuk wrote:
>>
>> 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 :
>> > So - replacing 'Module["asm"] =' 

Re: Similar Function Elimination

2017-08-23 Thread Александр Гурьянов
Sorry, missed error line from prev message:
TypeError: asm.js type error: double is not a subtype of intish

2017-08-23 13:42 GMT+07:00 Александр Гурьянов :
> Without -g2 I have this error:
> g[a+4>>2]=-$|0;
>
> In function:
> function Bg(a,b,$){a=a|0;b=b|0;$=+$;g[a>>2]=0.0;g[a+4>>2]=-$|0;return}
>
> And SFE on roll-a-ball project still does not work with same error. I
> start believe that I doing something wrong in build steps...
>
> P.S. My projects have a lot of undefined symbols (but they does not
> used), can this be a problem?
>
>
>
> 2017-08-23 13:34 GMT+07:00 Александр Гурьянов :
>> Hi. After your commit -g2 error gone. But my project does not work. I
>> see black screen (no errors, just black screen). And this error:
>>
>> TypeError: asm.js type error: void incompatible with previous return of type 
>> f64
>>
>> If I remove -g2 game works (but asm.js not). Btw, I trying to find how
>> to reporduce.
>>
>> The code for "asm.js type error: void incompatible with previous
>> return of type f64" is:
>>
>> function _roundf(d1){d1=+d1;(Jl(d1))}
>>
>> grep for _roundf in js:
>>>2]|0)+284>>2]|0;d37=+_roundf(+d28);d42=+_roundf(+
>>>2]|0)+284>>2]|0;d28=+_roundf(+d44);d42=+_roundf(+
>>>2]|0)+284>>2]|0;d50=+_roundf(+d37);FUNCTION_TABLE
>>>2]|0)+284>>2]|0;d50=+_roundf(+(d37+d28));FUNCTION
>> 1=HEAP32[i8>>2]|0;d2=+_roundf(+ +HEAPF32[i1+20>>2]
>> HEAP32[i10>>2]|0;d13=+_roundf(+(d2*+HEAPF32[i1+20>
>> AP32[i1+8>>2]|0;i9=~~+_roundf(+(+(i7|0)*1.5/+HEAPF
>>>2]|0;HEAPF32[i6>>2]=+_roundf(+d7);HEAPF32[i8>>2]=
>> =i1|0;var i2=0;i2=~~-+_roundf(+(+HEAPF64[i1+224>>3
>>  DO(i1,24)|0}function _roundf(d1){d1=+d1;(Jl(d1))}
>> serialization_pb_cpp, _roundf: _roundf, __GLOBAL__
>>
>> 2017-08-23 5:00 GMT+07:00 arnab choudhury :
>>> Hello caiiycuk - the latest commit to the master branch fixes this issue.
>>> Please let me know if you see any issues. Thanks for the due diligence!
>>>
>>> Regards,
>>> Arnab
>>>
>>>
>>> On Tuesday, August 22, 2017 at 12:36:23 PM UTC-7, arnab choudhury wrote:

 Thanks for catching this caiiycuk - I can repro and will have a fix out
 shortly. Looks like a name-clash bug in the minified name generator SFE
 uses.

 On Tuesday, August 22, 2017 at 10:17:15 AM UTC-7, caiiiycuk wrote:
>
> 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 :
> > 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 AM19,782,571 build.asm.js
> > 08/22/2017  09:39 AM

Re: Similar Function Elimination

2017-08-23 Thread Александр Гурьянов
Hi. After your commit -g2 error gone. But my project does not work. I
see black screen (no errors, just black screen). And this error:

TypeError: asm.js type error: void incompatible with previous return of type f64

If I remove -g2 game works (but asm.js not). Btw, I trying to find how
to reporduce.

The code for "asm.js type error: void incompatible with previous
return of type f64" is:

function _roundf(d1){d1=+d1;(Jl(d1))}

grep for _roundf in js:
>2]|0)+284>>2]|0;d37=+_roundf(+d28);d42=+_roundf(+
>2]|0)+284>>2]|0;d28=+_roundf(+d44);d42=+_roundf(+
>2]|0)+284>>2]|0;d50=+_roundf(+d37);FUNCTION_TABLE
>2]|0)+284>>2]|0;d50=+_roundf(+(d37+d28));FUNCTION
1=HEAP32[i8>>2]|0;d2=+_roundf(+ +HEAPF32[i1+20>>2]
HEAP32[i10>>2]|0;d13=+_roundf(+(d2*+HEAPF32[i1+20>
AP32[i1+8>>2]|0;i9=~~+_roundf(+(+(i7|0)*1.5/+HEAPF
>2]|0;HEAPF32[i6>>2]=+_roundf(+d7);HEAPF32[i8>>2]=
=i1|0;var i2=0;i2=~~-+_roundf(+(+HEAPF64[i1+224>>3
 DO(i1,24)|0}function _roundf(d1){d1=+d1;(Jl(d1))}
serialization_pb_cpp, _roundf: _roundf, __GLOBAL__

2017-08-23 5:00 GMT+07:00 arnab choudhury :
> Hello caiiycuk - the latest commit to the master branch fixes this issue.
> Please let me know if you see any issues. Thanks for the due diligence!
>
> Regards,
> Arnab
>
>
> On Tuesday, August 22, 2017 at 12:36:23 PM UTC-7, arnab choudhury wrote:
>>
>> Thanks for catching this caiiycuk - I can repro and will have a fix out
>> shortly. Looks like a name-clash bug in the minified name generator SFE
>> uses.
>>
>> On Tuesday, August 22, 2017 at 10:17:15 AM UTC-7, caiiiycuk wrote:
>>>
>>> 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 :
>>> > 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 AM19,782,571 build.asm.js
>>> > 08/22/2017  09:39 AM18,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 :
>>> >> > Hi caiiycuk
>>> >> >
>>> >> > I'll have an update here shortly. I would love to be able to
>>> >> > reproduce
>>> >> > the
>>> >> > 

Re: Similar Function Elimination

2017-08-22 Thread arnab choudhury
Hello caiiycuk - the latest commit 

 
to the master branch fixes this issue. Please let me know if you see any 
issues. Thanks for the due diligence!

Regards,
Arnab

On Tuesday, August 22, 2017 at 12:36:23 PM UTC-7, arnab choudhury wrote:
>
> Thanks for catching this caiiycuk - I can repro and will have a fix out 
> shortly. Looks like a name-clash bug in the minified name generator SFE 
> uses.
>
> On Tuesday, August 22, 2017 at 10:17:15 AM UTC-7, caiiiycuk wrote:
>>
>> 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 : 
>> > 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 AM19,782,571 build.asm.js 
>> > 08/22/2017  09:39 AM18,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 : 
>> >> > 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 Александр Гурьянов : 
>> >> >> > Roll a ball project: 
>> >> >> > https://www.assetstore.unity3d.com/en/#!/content/77198 
>> >> >> > 
>> >> >> > 2017-08-22 11:32 GMT+07:00 Александр Гурьянов : 
>>
>> >> >> >> 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 
>> 

Re: Similar Function Elimination

2017-08-22 Thread arnab choudhury
Thanks for catching this caiiycuk - I can repro and will have a fix out 
shortly. Looks like a name-clash bug in the minified name generator SFE 
uses.

On Tuesday, August 22, 2017 at 10:17:15 AM UTC-7, caiiiycuk wrote:
>
> 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  >: 
> > 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 AM19,782,571 build.asm.js 
> > 08/22/2017  09:39 AM18,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 : 
> >> > 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 Александр Гурьянов : 
> >> >> > Roll a ball project: 
> >> >> > https://www.assetstore.unity3d.com/en/#!/content/77198 
> >> >> > 
> >> >> > 2017-08-22 11:32 GMT+07:00 Александр Гурьянов : 
>
> >> >> >> 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);... 
> >> >> >> 
> >> 

Re: Similar Function Elimination

2017-08-22 Thread arnab choudhury
Hello caiiycuk

I just pushed an update to master - can you try pulling and trying on 
build.asm.js from your share? 

Thanks!
-Arnab

On Tuesday, August 22, 2017 at 10:37:41 AM UTC-7, caiiiycuk wrote:
>
> > 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%). 
>
> Hmm, no luck. Do you build Roll-a-ball with unity or you use my 
> archive. I tried you soultion on my build and it's does not work. 
> Steps: 
>
> git clone https://github.com/achoudhury85/Similar-Function-Elimination 
> unzip roll-a-ball.zip (from google drive) 
> sed s'/Module\["asm"\]/var asm/' build.asm.js > build.asm.var.js 
> node --max-old-space-size=8192 
> Similar-Function-Elimination/src/run_sfe.js --file build.asm.var.js > 
> build.asm.compat.js 
>
> Similar-Function-Elimination/src/similar_function_eliminator.js:179 
>   asmAst = node.declarations[0].init.callee.body; 
>^ 
>
> TypeError: Cannot read property 'body' of undefined 
> at SimilarFunctionEliminator.getAsmAst 
> (/home/caiiiycuk/tmp/Similar-Function-Elimination/src/similar_function_eliminator.js:179:48)
>  
>
> at SimilarFunctionEliminator.initialize 
> (/home/caiiiycuk/tmp/Similar-Function-Elimination/src/similar_function_eliminator.js:132:22)
>  
>
> at SimilarFunctionEliminator.run 
> (/home/caiiiycuk/tmp/Similar-Function-Elimination/src/similar_function_eliminator.js:1214:8)
>  
>
> at Object.run 
> (/home/caiiiycuk/tmp/Similar-Function-Elimination/src/similar_function_eliminator.js:1299:23)
>  
>
> at Object. 
> (/home/caiiiycuk/tmp/Similar-Function-Elimination/src/run_sfe.js:28:5) 
> at Module._compile (module.js:410:26) 
> at Object.Module._extensions..js (module.js:417:10) 
> at Module.load (module.js:344:32) 
> at Function.Module._load (module.js:301:12) 
> at Function.Module.runMain (module.js:442:10) 
>
> 2017-08-23 0:16 GMT+07:00 Александр Гурьянов  >: 
> > 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  >: 
> >> 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 AM19,782,571 build.asm.js 
> >> 08/22/2017  09:39 AM18,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 

Re: Similar Function Elimination

2017-08-22 Thread Александр Гурьянов
> 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%).

Hmm, no luck. Do you build Roll-a-ball with unity or you use my
archive. I tried you soultion on my build and it's does not work.
Steps:

git clone https://github.com/achoudhury85/Similar-Function-Elimination
unzip roll-a-ball.zip (from google drive)
sed s'/Module\["asm"\]/var asm/' build.asm.js > build.asm.var.js
node --max-old-space-size=8192
Similar-Function-Elimination/src/run_sfe.js --file build.asm.var.js >
build.asm.compat.js

Similar-Function-Elimination/src/similar_function_eliminator.js:179
  asmAst = node.declarations[0].init.callee.body;
   ^

TypeError: Cannot read property 'body' of undefined
at SimilarFunctionEliminator.getAsmAst
(/home/caiiiycuk/tmp/Similar-Function-Elimination/src/similar_function_eliminator.js:179:48)
at SimilarFunctionEliminator.initialize
(/home/caiiiycuk/tmp/Similar-Function-Elimination/src/similar_function_eliminator.js:132:22)
at SimilarFunctionEliminator.run
(/home/caiiiycuk/tmp/Similar-Function-Elimination/src/similar_function_eliminator.js:1214:8)
at Object.run
(/home/caiiiycuk/tmp/Similar-Function-Elimination/src/similar_function_eliminator.js:1299:23)
at Object.
(/home/caiiiycuk/tmp/Similar-Function-Elimination/src/run_sfe.js:28:5)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)

2017-08-23 0:16 GMT+07:00 Александр Гурьянов :
> 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 :
>> 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 AM19,782,571 build.asm.js
>> 08/22/2017  09:39 AM18,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 :
>>> > 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
>>> > 

Re: Similar Function Elimination

2017-08-22 Thread Александр Гурьянов
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 :
> 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 AM19,782,571 build.asm.js
> 08/22/2017  09:39 AM18,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 :
>> > 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 Александр Гурьянов :
>> >> > Roll a ball project:
>> >> > https://www.assetstore.unity3d.com/en/#!/content/77198
>> >> >
>> >> > 2017-08-22 11:32 GMT+07:00 Александр Гурьянов :
>> >> >> 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
>> 

Re: Similar Function Elimination

2017-08-22 Thread arnab choudhury
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 AM19,782,571 build.asm.js
08/22/2017  09:39 AM18,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  >: 
> > 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 Александр Гурьянов : 
> >> > Roll a ball project: 
> >> > https://www.assetstore.unity3d.com/en/#!/content/77198 
> >> > 
> >> > 2017-08-22 11:32 GMT+07:00 Александр Гурьянов : 
> >> >> 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 Александр Гурьянов : 
> >> >>> 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 : 
> >>  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. 

Re: Similar Function Elimination

2017-08-22 Thread Александр Гурьянов
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 :
> 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 Александр Гурьянов :
>> > Roll a ball project:
>> > https://www.assetstore.unity3d.com/en/#!/content/77198
>> >
>> > 2017-08-22 11:32 GMT+07:00 Александр Гурьянов :
>> >> 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 Александр Гурьянов :
>> >>> 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 :
>>  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
>> > 
>> > 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
>> >> 

Re: Similar Function Elimination

2017-08-22 Thread arnab choudhury
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 Александр Гурьянов  >: 
> > Roll a ball project: 
> https://www.assetstore.unity3d.com/en/#!/content/77198 
> > 
> > 2017-08-22 11:32 GMT+07:00 Александр Гурьянов  >: 
> >> 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 Александр Гурьянов  >: 
> >>> 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  >: 
>  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  
>
> > 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 

Re: Similar Function Elimination

2017-08-22 Thread Александр Гурьянов
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 Александр Гурьянов :
> Roll a ball project: https://www.assetstore.unity3d.com/en/#!/content/77198
>
> 2017-08-22 11:32 GMT+07:00 Александр Гурьянов :
>> 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 Александр Гурьянов :
>>> 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 :
 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 
> 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 emscripten-discuss+unsubscr...@googlegroups.com.
>> For more options, visit 

Re: Similar Function Elimination

2017-08-21 Thread Александр Гурьянов
Roll a ball project: https://www.assetstore.unity3d.com/en/#!/content/77198

2017-08-22 11:32 GMT+07:00 Александр Гурьянов :
> 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 Александр Гурьянов :
>> 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 :
>>> 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 
 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 emscripten-discuss+unsubscr...@googlegroups.com.
> 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 emscripten-discuss+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.

-- 
You received 

Re: Similar Function Elimination

2017-08-21 Thread Александр Гурьянов
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 Александр Гурьянов :
> 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 :
>> 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 
>>> 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 emscripten-discuss+unsubscr...@googlegroups.com.
 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 emscripten-discuss+unsubscr...@googlegroups.com.
>> 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 emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Similar Function Elimination

2017-08-21 Thread Александр Гурьянов
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 :
> 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 
>> 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 emscripten-discuss+unsubscr...@googlegroups.com.
>>> 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 emscripten-discuss+unsubscr...@googlegroups.com.
> 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 emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Similar Function Elimination

2017-08-21 Thread Alon Zakai
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 
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 emscripten-discuss+unsubscr...@googlegroups.com.
> 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 emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Similar Function Elimination

2017-08-21 Thread arnab choudhury
Hello Caiiycuk

This may be because there might be some code wrapping the asm.js. I'll try 
building UnityJS and get back to you. You currently have to run SFE 
separately after all optimizations and it has not been integrated into 
Emscripten (although if there is enough demand, we can consider doing this 
- currently we are just thinking of adding it straight to Binaryen).

Regards,
Arnab


On Sunday, August 20, 2017 at 11:56:29 PM UTC-7, caiiiycuk wrote:
>
> I tried this algorithm on Unity project, and I have this error: 
> /home/caiiiycuk/sdk/Similar-Function-Elimination/src/similar_function_eliminator.js:156
>  
>
>   var asmAstBody = this.asmAst.body; 
>   ^ 
>
> TypeError: Cannot read property 'body' of undefined 
> at SimilarFunctionEliminator.genFunctionNameToIndexDict 
> (/home/caiiiycuk/sdk/Similar-Function-Elimination/src/similar_function_eliminator.js:156:31)
>  
>
> at SimilarFunctionEliminator.initialize 
> (/home/caiiiycuk/sdk/Similar-Function-Elimination/src/similar_function_eliminator.js:134:8)
>  
>
> at SimilarFunctionEliminator.run 
> (/home/caiiiycuk/sdk/Similar-Function-Elimination/src/similar_function_eliminator.js:1214:8)
>  
>
> at Object.run 
> (/home/caiiiycuk/sdk/Similar-Function-Elimination/src/similar_function_eliminator.js:1299:23)
>  
>
> at Object. 
> (/home/caiiiycuk/sdk/Similar-Function-Elimination/src/run_sfe.js:28:5) 
> at Module._compile (module.js:410:26) 
> at Object.Module._extensions..js (module.js:417:10) 
> at Module.load (module.js:344:32) 
> at Function.Module._load (module.js:301:12) 
> at Function.Module.runMain (module.js:442:10) 
>
> 2017-08-20 12:44 GMT+07:00 Александр Гурьянов  >: 
> > Hi guys! Sorry, I don't understand from now SFE step is builtin into 
> > emscripten, or I should use it as post step after compilation? I want 
> > to try it on my projects. 
> > 
> > 2017-08-19 22:12 GMT+07:00 Charles Vaughn  >: 
> >> The biggest difference is SFE uses helper functions, since we need to 
> deal with finding pointers. It would be possible to generalize DFE and add 
> a specific optimization to elide helpers but we haven't done that. 
> >> 
> >> -- 
> >> 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 emscripten-discuss+unsubscr...@googlegroups.com . 
>
> >> 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 emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Similar Function Elimination

2017-08-21 Thread Александр Гурьянов
I tried this algorithm on Unity project, and I have this error:
/home/caiiiycuk/sdk/Similar-Function-Elimination/src/similar_function_eliminator.js:156
  var asmAstBody = this.asmAst.body;
  ^

TypeError: Cannot read property 'body' of undefined
at SimilarFunctionEliminator.genFunctionNameToIndexDict
(/home/caiiiycuk/sdk/Similar-Function-Elimination/src/similar_function_eliminator.js:156:31)
at SimilarFunctionEliminator.initialize
(/home/caiiiycuk/sdk/Similar-Function-Elimination/src/similar_function_eliminator.js:134:8)
at SimilarFunctionEliminator.run
(/home/caiiiycuk/sdk/Similar-Function-Elimination/src/similar_function_eliminator.js:1214:8)
at Object.run
(/home/caiiiycuk/sdk/Similar-Function-Elimination/src/similar_function_eliminator.js:1299:23)
at Object.
(/home/caiiiycuk/sdk/Similar-Function-Elimination/src/run_sfe.js:28:5)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)

2017-08-20 12:44 GMT+07:00 Александр Гурьянов :
> Hi guys! Sorry, I don't understand from now SFE step is builtin into
> emscripten, or I should use it as post step after compilation? I want
> to try it on my projects.
>
> 2017-08-19 22:12 GMT+07:00 Charles Vaughn :
>> The biggest difference is SFE uses helper functions, since we need to deal 
>> with finding pointers. It would be possible to generalize DFE and add a 
>> specific optimization to elide helpers but we haven't done that.
>>
>> --
>> 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 emscripten-discuss+unsubscr...@googlegroups.com.
>> 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 emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Similar Function Elimination

2017-08-19 Thread Александр Гурьянов
Hi guys! Sorry, I don't understand from now SFE step is builtin into
emscripten, or I should use it as post step after compilation? I want
to try it on my projects.

2017-08-19 22:12 GMT+07:00 Charles Vaughn :
> The biggest difference is SFE uses helper functions, since we need to deal 
> with finding pointers. It would be possible to generalize DFE and add a 
> specific optimization to elide helpers but we haven't done that.
>
> --
> 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 emscripten-discuss+unsubscr...@googlegroups.com.
> 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 emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Similar Function Elimination

2017-08-19 Thread Charles Vaughn
The biggest difference is SFE uses helper functions, since we need to deal with 
finding pointers. It would be possible to generalize DFE and add a specific 
optimization to elide helpers but we haven't done that.

-- 
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 emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Similar Function Elimination

2017-08-18 Thread arnab choudhury
Hey Floh

This document 

 covers 
Similar Function Elimination in detail. It is a more general version of 
DFE. The main difference between the two is that while in DFE we hash 
function bodies, in SFE, we first canonicalize the AST of the function body 
- we replace all identifiers and literals with placeholders, and then hash 
the function body. Functions whose canonicalized ASTs hash to the same 
value can be coalesced into helper functions (where the similar functions' 
bodies will be replaced by a call to the helper function). 

SFE can hence replace DFE and yields a larger reduction in code size than 
DFE. Hope this helps.

Regards,
Arnab

On Friday, August 18, 2017 at 1:24:15 PM UTC-7, Floh wrote:
>
> Nice to see progress in that area :) What are the differences to the 
> existing DFE pass? Since both are from you guys I guess the Similar 
> Function Elimination is an improvement over the Duplicate Function 
> Elimination? Is the new SFE supposed to replace DFE, or are they 
> independent from each other?
>
> Thanks!
> -Floh.
>
> Am Freitag, 18. August 2017 17:24:32 UTC+2 schrieb arnab choudhury:
>>
>> 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 emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Similar Function Elimination

2017-08-18 Thread Floh
Nice to see progress in that area :) What are the differences to the 
existing DFE pass? Since both are from you guys I guess the Similar 
Function Elimination is an improvement over the Duplicate Function 
Elimination? Is the new SFE supposed to replace DFE, or are they 
independent from each other?

Thanks!
-Floh.

Am Freitag, 18. August 2017 17:24:32 UTC+2 schrieb arnab choudhury:
>
> 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 emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.