From f06dfed6a60d67360fb2daca0d4bbe02caa0149c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Thu, 13 Jun 2013 16:10:35 +0300 Subject: [PATCH 01/51] Improve absolute path warning detection to work on Windows, and make the warning message more informative. --- emcc | 7 ++++--- tests/runner.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/emcc b/emcc index 2a7e10d0fcad6..5ec42869428f5 100755 --- a/emcc +++ b/emcc @@ -853,9 +853,10 @@ try: memory_init_file = int(newargs[i+1]) newargs[i] = '' newargs[i+1] = '' - elif newargs[i].startswith(('-I/', '-L/')): - if not absolute_warning_shown: - logging.warning ('-I or -L of an absolute path encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript)') # Of course an absolute path to a non-system-specific library or header is fine, and you can ignore this warning. The danger are system headers that are e.g. x86 specific and nonportable. The emscripten bundled headers are modified to be portable, local system ones are generally not + elif newargs[i].startswith(('-I', '-L')): + path_name = newargs[i][2:] + if not absolute_warning_shown and os.path.isabs(path_name): + logging.warning ('-I or -L of an absolute path "' + newargs[i] + '" encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript)') # Of course an absolute path to a non-system-specific library or header is fine, and you can ignore this warning. The danger are system headers that are e.g. x86 specific and nonportable. The emscripten bundled headers are modified to be portable, local system ones are generally not absolute_warning_shown = True newargs = [ arg for arg in newargs if arg is not '' ] diff --git a/tests/runner.py b/tests/runner.py index 5e1010243d22f..2f755edd3328a 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -10507,7 +10507,7 @@ def test_abspaths(self): (['-Lsubdir/something'], False), ([], False)]: err = Popen([PYTHON, EMCC, 'main.c'] + args, stderr=PIPE).communicate()[1] - assert ('-I or -L of an absolute path encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript)' in err) == expected, err + assert ('encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript)' in err) == expected, err def test_local_link(self): # Linking a local library directly, like /usr/lib/libsomething.so, cannot work of course since it From 59687f98cc7aebd5b6b0e069986b9dba483a605b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Thu, 13 Jun 2013 16:21:07 +0300 Subject: [PATCH 02/51] Improve emcc input file detection to ignore all arguments that precede a GCC preprocessor command line option from http://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html . --- emcc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emcc b/emcc index 2a7e10d0fcad6..590f4040237a7 100755 --- a/emcc +++ b/emcc @@ -902,7 +902,7 @@ try: if i > 0: prev = newargs[i-1] - if prev in ['-MT', '-install_name', '-I', '-L']: continue # ignore this gcc-style argument + if prev in ['-MT', '-MF', '-MQ', '-D', '-U', '-o', '-x', '-Xpreprocessor', '-include', '-imacros', '-idirafter', '-iprefix', '-iwithprefix', '-iwithprefixbefore', '-isysroot', '-imultilib', '-A', '-isystem', '-iquote', '-install_name', '-I', '-L']: continue # ignore this gcc-style argument if (os.path.islink(arg) and os.path.realpath(arg).endswith(SOURCE_SUFFIXES + BITCODE_SUFFIXES + DYNAMICLIB_SUFFIXES + ASSEMBLY_SUFFIXES)): arg = os.path.realpath(arg) From 45de2f170796d9fe3b17f4d9e3539b46fd6a056a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Thu, 13 Jun 2013 16:49:36 +0300 Subject: [PATCH 03/51] Don't throw when SDL_CreateRGBSurfaceFrom is called, but at least give an uninitialized surface. --- src/library_sdl.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/library_sdl.js b/src/library_sdl.js index a131f4241c0ea..6adfc1e2c9b9e 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -965,6 +965,13 @@ var LibrarySDL = { return SDL.makeSurface(width, height, flags, false, 'CreateRGBSurface', rmask, gmask, bmask, amask); }, + SDL_CreateRGBSurfaceFrom: function(pixels, width, height, depth, pitch, rmask, gmask, bmask, amask) { + // TODO: Actually fill pixel data to created surface. + // TODO: Take into account depth and pitch parameters. + console.log('TODO: Partially unimplemented SDL_CreateRGBSurfaceFrom called!'); + return SDL.makeSurface(width, height, 0, false, 'CreateRGBSurfaceFrom', rmask, gmask, bmask, amask); + }, + SDL_DisplayFormatAlpha: function(surf) { var oldData = SDL.surfaces[surf]; var ret = SDL.makeSurface(oldData.width, oldData.height, oldData.flags, false, 'copy:' + oldData.source); @@ -1837,7 +1844,6 @@ var LibrarySDL = { Mix_FadeOutChannel: function() { throw 'Mix_FadeOutChannel' }, Mix_Linked_Version: function() { throw 'Mix_Linked_Version: TODO' }, - SDL_CreateRGBSurfaceFrom: function() { throw 'SDL_CreateRGBSurfaceFrom: TODO' }, SDL_SaveBMP_RW: function() { throw 'SDL_SaveBMP_RW: TODO' }, SDL_HasRDTSC: function() { return 0; }, From 5b41371bb5897a49e1fdcad18d053f775105c846 Mon Sep 17 00:00:00 2001 From: Michael Bishop Date: Thu, 13 Jun 2013 12:46:44 -0400 Subject: [PATCH 04/51] Added test for SDL_Mix that includes looping audio. The test demonstrates that looping produces gaps in the sound. --- tests/runner.py | 3 ++- tests/sdl_audio_mix.c | 12 +++++++++++- tests/sounds/noise.ogg | Bin 0 -> 9205 bytes 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 tests/sounds/noise.ogg diff --git a/tests/runner.py b/tests/runner.py index 5e1010243d22f..d6ac8a5d3a786 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -12279,9 +12279,10 @@ def test_sdl_audio(self): def test_sdl_audio_mix(self): shutil.copyfile(path_from_root('tests', 'sounds', 'pluck.ogg'), os.path.join(self.get_dir(), 'sound.ogg')) shutil.copyfile(path_from_root('tests', 'sounds', 'the_entertainer.ogg'), os.path.join(self.get_dir(), 'music.ogg')) + shutil.copyfile(path_from_root('tests', 'sounds', 'noise.ogg'), os.path.join(self.get_dir(), 'noise.ogg')) open(os.path.join(self.get_dir(), 'sdl_audio_mix.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_audio_mix.c')).read())) - Popen([PYTHON, EMCC, '-O2', '--minify', '0', os.path.join(self.get_dir(), 'sdl_audio_mix.c'), '--preload-file', 'sound.ogg', '--preload-file', 'music.ogg', '-o', 'page.html']).communicate() + Popen([PYTHON, EMCC, '-O2', '--minify', '0', os.path.join(self.get_dir(), 'sdl_audio_mix.c'), '--preload-file', 'sound.ogg', '--preload-file', 'music.ogg', '--preload-file', 'noise.ogg', '-o', 'page.html']).communicate() self.run_browser('page.html', '', '/report_result?1') def test_sdl_audio_quickload(self): diff --git a/tests/sdl_audio_mix.c b/tests/sdl_audio_mix.c index f72f9c43770ee..a1c0485d18173 100644 --- a/tests/sdl_audio_mix.c +++ b/tests/sdl_audio_mix.c @@ -5,9 +5,11 @@ #include static Mix_Chunk *sound = NULL; +static Mix_Chunk *noiseLoop = NULL; static Mix_Music *music = NULL; static int soundChannel = 0; +static int noiseLoopChannel = 0; void one_iter(); void one_iter() { @@ -19,6 +21,12 @@ void one_iter() { soundChannel = Mix_PlayChannel(-1, sound, 0); printf("channel = %d", soundChannel); assert(soundChannel != -1 && soundChannel != 0); + + noiseLoopChannel = Mix_PlayChannel(-1, noiseLoop, -1); + printf("noiseLoopChannel = %d", noiseLoopChannel); + assert(noiseLoopChannel != -1 && noiseLoopChannel != 0); + // set noiseLoopChannel to half volume + Mix_Volume(noiseLoopChannel,MIX_MAX_VOLUME/10); break; case 2: printf("channel %d is playing = %d", soundChannel, Mix_Playing(soundChannel)); @@ -70,9 +78,11 @@ int main(int argc, char **argv) { sound = Mix_LoadWAV("sound.ogg"); assert(sound); + noiseLoop = Mix_LoadWAV("noise.ogg"); + assert(noiseLoop); + music = Mix_LoadMUS("music.ogg"); assert(music); - emscripten_set_main_loop(one_iter, 30, 0); // force a quit diff --git a/tests/sounds/noise.ogg b/tests/sounds/noise.ogg new file mode 100644 index 0000000000000000000000000000000000000000..c53d49a703c00bdc187c162586b37efd288cc0fa GIT binary patch literal 9205 zcmaiZ2V7Il()Wqa7zyP6l1r-G8 zy(2}c6h%S6g7TffbMJk=`+dLn-QQ-jXJ>b2cjiBHW|LcXcKW~>;O`Pz0;eE$w@~kR zAQvIt_uZ}RJ%|Gkl``TNSbQKSUyYDk#FhUp#Fa$KYyB->dXeM*t8|l`GU5X1#`doF zL~ps95zqDHw~*n>~)AmrD3Bw*sNpVo&Rc}k~Yi$Knes2P{kFjX*vwZ+OhG+x#!B- z>s&2{Qbg-5%2KuMU$%BBsx5MK8G!Loo;4u@KusuVaECFWh>cYwcQ_l^L~y!yaTjN~ zQwu)NeM~Lh1r5;>-zZGhk=uA)5GS`OP&=edBT_qp(1MQ}T9>zwTLgFv$gXGo-B6vJ z0}Ad%nVj8*UYU}}J`z@x<_@wtJr)!Q0*?u(Co*YPG4)n)_7C&k+7;Gglp2;$)i=;a zgT>3j$Qv{1?KSBgXp$CY));8g7-lvVW^ovHmo5D7`aN*rkXTQS4ut@@JhG|Fu>4CG z@|R@uNkYTR&Hy$dE<%I!1j@0Hd&_f`w{R@0tL0U+QMV#&47DEfb@ ztw}28f3HgSxwP?zuAIN!PPs-k$`xeHUAXt)aiZK{M4?r@h>_mF(&aUHDco+{l~ zt^RLX=l*2`qS*mJ3C`K!#@P*O10^!*E@k8)Kk1=8395pqk^i{_pWp>N2zRz^szVT^ zM8e$@wFH4|+43lF(w<5JCq(A0Kr@Ci_WEV%GFEf(Oqru^q6{+moA7CwCl+)XU|$Ap z3F}Gk$W0&0@EFjf&A^@Zd>Jw+2>20jjD0<4f~)J&#h6O{$n`(cyyxu1$S_TTVP0_}EpimfyIF*Goa z+=_|2h&%bBXFOeUF1!m?cri9k4S^5QMX~eaJRhH&90~xT^d~6(S91d8Qxq2_MGN)_ z)bxq>3KN^M_5r!A%69sjv~Uo`!criLW9!zQd6dg)IO6IiOoeb*6at1j^(fG&P@9As zx;QPmI5K)YGEN{W z)jletq$%I2r+lmVf35%a9CdeIu!5eW>dyNQ&v^~!ya{?!wXpWy=^5pRL4|s%vi{Qm zU=&WEMV`bFJ(S2eN@^S>f;N!pzI=VObK7( zCCif~&wI-jT1+oND|_~mXTlAB`NkyKcG|r~lmN4eR!A(LOdRxVTamfu>QzcG?2!U` z01yQ4g1=>RAJFX1RT+R&Wn;T!`Eki3nlO=6HVGJC5rg$|R>6p7cOjMy8J%6oU>!vO z7XcLDhbC_*ff=I21OQgFC~8<37Bv7{OF;F&S2lE>b_hKT$EiO6 zd&e2tcVjgxWax$f06l(kq>U;-&kroR@(w0TBANJ*jH-i7m`O(M$rQT6FkqtW%~ z>3wH(YTyS?w1p97`Veix^3ZHD?88Ce2R0(-$#E}`dUpbIx4~;cz&^v?A^&+vhCoRP zzNFr{q?}-u|FI;$q^H`hq`a)Bx}vn)X$z#5KQE~kE-4W%tuFgjBD_`qyrh}XQ(c)^ zUb9u3 z%AV?-t>!DWUfgyjlaFbgskCaf+CGI3^;vH2yN&4RtHpdk4B z&ikA%#5gTxr9nb=HGwA3y6cc?&~diY?U&s0fmcBVE!Det5E~F8HW+)9^0LMJtv15XrP=h$luB>DR#61{x1VxdD(?vMu zVJA?IRYhY~pP+>-2zwFih^YgzONSIB}y!0VaJT;LO&;EF;9Gfh}0lfJV^X9iCv6lB#+6n-LO zH4O{0N)JgwAP6Z*sJ^UZBCC)%geI&$384k<3W2B!Lzz0kC$dmZQsAyYR!Imakxo-H ztvWAyQ<{@q5$X&b9SEJEa6TLx5>Zvh;^+cjyMVAK5QXDASj^%;;rfnJMH3E0f|;}Y zM1}`~FfoRT1qs&9E#n#fJO4Vlm4iskfr3qu^-DBwE!OdSZdQ%aPC zunBP_9|#3o!rL@cApqD0H?(~cNBDpQ3P6di0F*0hM{m_9`;k);jEtP2bb_5(A#}== z%-}Y_cU7M(*w8D31Tf#r3jrG(c7#YkAvU1k7!2o0Bw$h003hfJW<-^GHXe@?bHSK- z2Jj`uOoS{&9##$33B@L%Kyl!a@b0vr?m7&K1gz;c6oiJ8ls7#Ht4`CK2ttRkV>vf& z!m3Pa5(IJGT81M6Bslgr0l<4Q3ZRmNLsgoejY?3`=Hw7TP*9CA@Ng!pX!v^8O-fit z8kpl0u@O@b@Fh#kKVm=v_}B>&WY;-~O_oR8e-e}b^r-$nhrok*)_FtlZQaSnL3x^$ zt1+BBT08xnq^F%e{v&7qPxk&l^~@XzAmskp07|c@DS%@N4ny^;unRQ8#52;gWV9~`D2-2u@3r{JmX&YWVu{AfCY%8B=n|LumfwsscqJ>)p z0iueC5$;gX45wqE3I86Wms>xD76_>I(|K53GLLnNF)^`u9|O;p#(WbV_o#9R=BCnE6aZLIs$B$W7 zF?zSMtr76{GOQs&Ao1~tds&@#A9#m^QUYT1+!Db`5GJ-RP*5l-49Kl~Jp?x=C0$_< zr>3QT7wR!$PXf?~cF`tA8q+c`mIUWp$pOaZce*HoXk%k*pU`|1e@$lb-U}KECFPFn zfG{Nlg)q82SUP*F@eP%nDvs{-$_oK50zlGP=%q^;vT=0r=Mv}>&nGb?Gh#vb0>C09 z=o}ElOBNX!X&YD2zD&ZaViQ{Uc7>GhgiLHGDNnB|q$mB;EAeZ!Q!?>NOcX=w+APH+ zE%9k(WpRCF_2b;qht0LkwT-0@p2}o=u}KM!+upP4anEgK#uI!(+U>mpswW~S)F)fb znfN6G{Ji^ie}z7acO0H9SlHg)QwI8U@+5VofR_$uR(HQTqvK1WVxRop9h){2eKDLO zG{!q1mU?YCCm9CsM%4B#=Io?TlQ#G829q+0LFS8dDh9*#JTsjsluQGiJ4Tc_2)@-B zLZUW@&Zo!N2%s=^ zXh;f2=JtwCV>vOOYA3!;B~tu#&XTh-P@!&hDuU+rO7BY}b-MwVqoE^%lH2^Vt=hFU zaz5;ruEH^!<6D782ajU8;m)+~GY<}I=qY1aSxX8$k!l`{Kf8zK;6_RVKWXUkB6r@v z(!%}}wpDU{ISReBf76*PoEFA4cKNLcoGC{=?e++KjzI!tm1SPpnnJ>t>>54PTMN_J zZT4r;V0{#4S6Q)Q?lBmphjvBejFO9qkA3!d_&tEq;W3ItFx$mo;S)P4LR491_PQ}y zhesN7gJv@D@clQ{GZ4UafjK%%;f_;j{)ActsblNWhmRdkZXb7lvu-zfHZ$k9nzIn{ zM_c~`if^}*-&bac>v)LCo6aHfLlWF|)%GpbHxG;gT#gnga2p>u8y@9S#d>tR5%D>q3qxAc=UA^M4qH z8g~vptv};dPuDvfm|ilNM0AY@Y;R_7s&Tigaea5jmy61)W!-#r8M|cp%dWvjvx&n- zN$Olm3>q!CS?ckwe#yWunp(Z;i6-JfZ@l^P=b;g5AL235XCRbmi$~x4M;V^KtuUk^ zgibt;zn*sO+plTI`>&)ogcJv*Ev7zM&VIo-FgwNGG)vBub_!Utuzb4ktHmvCTW@qc z?2YUW&Z)?WrLYzT6Z$c_jyDs(z8Do9DBjSvqVh?VFP+4~3DY);9(v`QQcTpEQc<>#8-X zW-(^ZBvoWpHAW5$S#!2toKvi76oSY;DSVkLuOE}dl<@h-u$E@H)Wn)-xGB&l#$Piy z^+Wq6U@0s$ALP&N0I*6)t0X6E)SHl#q3v4lQifuuZl_6Kp4%Aw*Pp{ozOB^8qzxjj}2{GR5OnWBuLx zua7#WevM2@^P6nEl0<2U3f`ONw;vR{)mD7_1~0$Wns>=$KfhkMtG zMz?~<3V-iw9E%TlPSzhpH-E((X!ooZwz(I+wK^Ic>)kJJ; zRJNN<-XE4-dm*Qx6=}u`faQBhOA_FK^u23{9Vf4@W*m&L{W4HC%9Nt}3&(fO7NY;45v!x@z*bTWBYW_0^>-FMyh(AKkAl!(w zOmjVnVPU=T{zm;8PxWxTOp4B$+!nInQ`<8gnJYKgrL+=THYTmgl5Kb2@?1Sfb@?J* z`jx2ad=uh2NjY_al!TzdJF`wPDRDGRH|K*QCNrfuoFL#{V%6hz<)zJrd$}!b>G8bF zSU@*9_h7h*)OGHm?_rdAqVEQs#=mV@3?=8H&+I6wl^g1cw@%HW_RG zIeX?s@|)qX)hlv$c;Eeg2QN75?7T;d+}sbeO! zQ)kIvaqHZ4w(UI=__Rvo_ma3FPqg-Z6{ITDx$O%yf*u2m`?Z*P<)A4~t{w5iAU$h>SB z&A!+y{LwGZYFSsNh2!g`iqEbelju`Ry?!h5e_VI2HR1`3a4)~LBlvP>Z{YmQ3Taf~ z{z^HYSA*L5BR2gnVeMt*9yBx`4{cg+a5Cy>O8facn;dQyCP=RZ-{17UR@TyPZWBxy z8hs}*TwCp-eb^sZQXnI}b*la9g;tYfx_y&-D^xlIkQca$RvaUYg+su({xIc9o8`py z^Nv!jYLY3zMZRrH!Uj)!E@W59^|Iyo%3QTyE+0qp=Su<)X=C*OH1K+#$Ap@`yfz<3 zsN0pi-4d|E8WEARH*H$6E;@TX$6uzeN6X1vE={%wr*AL(W8-zI!WqUM>Y-YiIg1f; zFFENN{VT&l@`F<@U0vmVS&pj*i8kS$BFxTD5s%cf4^69;b3HCUqKH4+QCoiXF57X> zhYs&Z@s;cMK0V%~=Pz|ud)Zr_=wDx6a*oGqvD6JKcIOwqwDe&JvM&l|T9fHSX=$6f zItFVaggnSk`Gi@|wP-akNe^L4+jDA0uI25!RA);+$g6Ui z`&=Va} zIq>f7#c|$%7mL!wT0U`!Z?F{8S~b#Dk%xDYOXlW1D9l@qu6O#d5%XgW^DYzT1e%y2krtrp3Q_rqX1qK6EDH+32Wo zo~>wnW@FHcf{>oOjl5;xYDC+9T4fG39ec}Q5K>2tZh=r+u^7ilU``d z^b(~+VL4j}{`CdCr%%zPd|kUz;;zl}uVkotoi_v|rUA>?pr=cY$nVI0% zd7ml;UWBKmC@M9n=ERhr$6XXCy!!OI#HSkSWimUqjf`F?pEQLT{^Tpelz{>sFJ}yF zS#7-cS%n%^D4s2`IkgeX_-{f z8wUBfSizO$0`-vW-kEJD)KOtfp?dKvhJ&xNgX5 zw94nHj40nX&H7`F8Xdazw}c6r3?F!4N~RtvmJwP1V5oUcP?ak1psXxu;8*-z3S9<6 zuaTg@njylkqFEN}?lfex*}ApfBgET)3jZpJl2=_rqc*zUY2g=Lwd|L5nuo4S{Pp`H z)2sL5f5OF+zE1uQ<-abXwdZzyh>JZw{Jheo*h`FJ9cdqU;XjeKiBIjTZ`H~r{a~G# zaUEnivghc%W1rzv$kkPs;`(RZIr!JuYRs8WI95+8#xY@;whK0HbvI`|1(c<53OU^c zEVswTAz-LQ)>$!fk`&+CRgV$nckH{%~V^ zzb5a!4d9hEx-_jBhf11%Q`yXQ85A3pdsYF}s_cr0sFtojCqau*`m0z+yz2J17 zoH@%24eR?thyCc{i#|ISvs%H4@7FoK1 zLPp)OA9yf(A)zH&Jx;?pZk+Vw2Mf|_@V8rHA^u=N0)7Xr4JcA=t{$Hg7LvLu{%|`+ z6C8biNu5TQ&3dfW+&%qy`nlVFm~NTY-FvU>9ftnQ9*0bxvpKFOxzZNG`p7g@Z1JxL z0i+kCHS!ag0+$nzy!*d3wh`tdDb_Lye%2OBwV$*4>+p;V41$Dd)~$-V%%oE?X9-T2XkSEj9QqZ*WOQ{zL$$u zX%qN#beCkfI`hO|(XK-DE0D90!h$#B>e)f%2$bb9b$2$t^a(67GD=TGrCeU^b+v-O zt}`iZQ(EL>LvmK+x=^eATZH0qbUp)^;o7K?(A@)y?ZSP|vbEczB~7VtT*tpw!w63u zW_yolC7feo?Uy_JTc(WGR35LH(rntBo7|Ib(N-%A^Ly!Zy*x$M%j(ImDQ`c7o1@uf zpU2{UTD5m?4&2wR!0bjMtf-L^UnHcJqpohnq;G%wH=`VOgL#V-zq(`(MA72U+7 zlV?hkN?hLC3|6Vw`Gc93xXC8b+=I_~U$X3d=>xRoDb2Q&SKzy;%yh(X=K@7p$~GUT zXn>bjgMIhQ&CDYK8Qoge5odE>lH7%E<_C8BbPu2}iztiGQFqAASGs+JQ_j@?TzO8B zuS7CG>*jV%QB8iv1u3*2P`FyW`c$|<`vLIf!J`&C^EW`8A zQw#MRw5W-t*Bm8(5))SG{wnmi_s&+(m!I|VzO=5UPPYDPex6<>AM_c&MbDlzL5PF5iY=m0?Q|B}fh+ zaPH_gdI-5xv4QzR>;L}Yy>frU?MJZ>%`WOU{K-;OC>EA>SiD_x3-=H~R%;bTS+X*q zKLg1P8P_38 zgmGjE!A-0QhDQ(k()7KZ{^U-Xw%4}GPYAu7kUTd1&h{#mDMryMZLhTBxCHWl06%zz A4gdfE literal 0 HcmV?d00001 From 15b236a68796330670aa7795e3907a1f956f127e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Thu, 13 Jun 2013 21:54:11 +0300 Subject: [PATCH 05/51] Report debug diagnostics in file packager if EMCC_DEBUG=1. Make file packager skip all path components that have a path starting with '.', like ('.git/xxx/yyy/'), or the filename starts with '.', or the file is a Win32 hidden file. Explicitly specified files on the command line are always packaged, even if they start with '.' or are hidden. Add unit tests to check that it works. --- tests/runner.py | 35 +++++++++++++++++++++++------------ tools/file_packager.py | 40 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 60 insertions(+), 15 deletions(-) diff --git a/tests/runner.py b/tests/runner.py index 5e1010243d22f..7f8c2d87688bc 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -11804,6 +11804,9 @@ def test_compression(self): def test_preload_file(self): absolute_src_path = os.path.join(self.get_dir(), 'somefile.txt').replace('\\', '/') open(absolute_src_path, 'w').write('''load me right before running the code please''') + + absolute_src_path2 = os.path.join(self.get_dir(), '.somefile.txt').replace('\\', '/') + open(absolute_src_path2, 'w').write('''load me right before running the code please''') def make_main(path): print path @@ -11828,6 +11831,7 @@ def make_main(path): test_cases = [ # (source preload-file string, file on target FS to load) ("somefile.txt", "somefile.txt"), + (".somefile.txt@somefile.txt", "somefile.txt"), ("./somefile.txt", "somefile.txt"), ("somefile.txt@file.txt", "file.txt"), ("./somefile.txt@file.txt", "file.txt"), @@ -11856,11 +11860,13 @@ def make_main(path): # Test subdirectory handling with asset packaging. os.makedirs(os.path.join(self.get_dir(), 'assets/sub/asset1/').replace('\\', '/')) + os.makedirs(os.path.join(self.get_dir(), 'assets/sub/asset1/.git').replace('\\', '/')) # Test adding directory that shouldn't exist. os.makedirs(os.path.join(self.get_dir(), 'assets/sub/asset2/').replace('\\', '/')) open(os.path.join(self.get_dir(), 'assets/sub/asset1/file1.txt'), 'w').write('''load me right before running the code please''') + open(os.path.join(self.get_dir(), 'assets/sub/asset1/.git/shouldnt_be_embedded.txt'), 'w').write('''this file should not get embedded''') open(os.path.join(self.get_dir(), 'assets/sub/asset2/file2.txt'), 'w').write('''load me right before running the code please''') absolute_assets_src_path = os.path.join(self.get_dir(), 'assets').replace('\\', '/') - def make_main_two_files(path1, path2): + def make_main_two_files(path1, path2, nonexistingpath): open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(self.with_report_result(r''' #include #include @@ -11879,24 +11885,29 @@ def make_main_two_files(path1, path2): if (f == NULL) result = 0; fclose(f); + + f = fopen("%s", "r"); + if (f != NULL) + result = 0; + REPORT_RESULT(); return 0; } - ''' % (path1, path2))) + ''' % (path1, path2, nonexistingpath))) test_cases = [ - # (source directory to embed, file1 on target FS to load, file2 on target FS to load) - ("assets", "assets/sub/asset1/file1.txt", "assets/sub/asset2/file2.txt"), - ("assets/", "assets/sub/asset1/file1.txt", "assets/sub/asset2/file2.txt"), - ("assets@/", "/sub/asset1/file1.txt", "/sub/asset2/file2.txt"), - ("assets/@/", "/sub/asset1/file1.txt", "/sub/asset2/file2.txt"), - ("assets@./", "/sub/asset1/file1.txt", "/sub/asset2/file2.txt"), - (absolute_assets_src_path + "@/", "/sub/asset1/file1.txt", "/sub/asset2/file2.txt"), - (absolute_assets_src_path + "@/assets", "/assets/sub/asset1/file1.txt", "/assets/sub/asset2/file2.txt")] + # (source directory to embed, file1 on target FS to load, file2 on target FS to load, name of a file that *shouldn't* exist on VFS) + ("assets", "assets/sub/asset1/file1.txt", "assets/sub/asset2/file2.txt", "assets/sub/asset1/.git/shouldnt_be_embedded.txt"), + ("assets/", "assets/sub/asset1/file1.txt", "assets/sub/asset2/file2.txt", "assets/sub/asset1/.git/shouldnt_be_embedded.txt"), + ("assets@/", "/sub/asset1/file1.txt", "/sub/asset2/file2.txt", "/sub/asset1/.git/shouldnt_be_embedded.txt"), + ("assets/@/", "/sub/asset1/file1.txt", "/sub/asset2/file2.txt", "/sub/asset1/.git/shouldnt_be_embedded.txt"), + ("assets@./", "/sub/asset1/file1.txt", "/sub/asset2/file2.txt", "/sub/asset1/.git/shouldnt_be_embedded.txt"), + (absolute_assets_src_path + "@/", "/sub/asset1/file1.txt", "/sub/asset2/file2.txt", "/sub/asset1/.git/shouldnt_be_embedded.txt"), + (absolute_assets_src_path + "@/assets", "/assets/sub/asset1/file1.txt", "/assets/sub/asset2/file2.txt", "assets/sub/asset1/.git/shouldnt_be_embedded.txt")] for test in test_cases: - (srcpath, dstpath1, dstpath2) = test - make_main_two_files(dstpath1, dstpath2) + (srcpath, dstpath1, dstpath2, nonexistingpath) = test + make_main_two_files(dstpath1, dstpath2, nonexistingpath) print srcpath Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', srcpath, '-o', 'page.html']).communicate() self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?1') diff --git a/tools/file_packager.py b/tools/file_packager.py index 1443d1658e0fb..1025207d65c04 100644 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -39,7 +39,7 @@ to dds files in the browser, exactly the same as if this tool compressed them. ''' -import os, sys, shutil, random, uuid +import os, sys, shutil, random, uuid, ctypes import shared from shared import Compression, execute, suffix, unsuffixed @@ -50,6 +50,8 @@ See the source for more details.''' sys.exit(0) +emcc_debug = os.environ.get('EMCC_DEBUG') + data_target = sys.argv[1] IMAGE_SUFFIXES = ('.jpg', '.png', '.bmp') @@ -150,6 +152,32 @@ } ''' +# Win32 code to test whether the given file has the hidden property set. +def has_hidden_attribute(filepath): + if sys.platform != 'win32': + return False + + try: + attrs = ctypes.windll.kernel32.GetFileAttributesW(unicode(filepath)) + assert attrs != -1 + result = bool(attrs & 2) + except (AttributeError, AssertionError): + result = False + return result + +# The packager should never preload/embed any directories that have a component starting with '.' in them, +# or if the file is hidden (Win32). Note that this filter ONLY applies to directories. Explicitly specified single files +# are always preloaded/embedded, even if they start with a '.'. +def should_ignore(filename): + if has_hidden_attribute(filename): + return True + + components = filename.replace('\\\\', '/').replace('\\', '/').split('/') + for c in components: + if c.startswith('.'): + return True + return False + # Expand directories into individual files def add(arg, dirname, names): # rootpathsrc: The path name of the root directory on the local FS we are adding to emscripten virtual FS. @@ -158,8 +186,12 @@ def add(arg, dirname, names): for name in names: fullname = os.path.join(dirname, name) if not os.path.isdir(fullname): - dstpath = os.path.join(rootpathdst, os.path.relpath(fullname, rootpathsrc)) # Convert source filename relative to root directory of target FS. - data_files.append({ 'srcpath': fullname, 'dstpath': dstpath, 'mode': mode }) + if should_ignore(fullname): + if emcc_debug: + print >> sys.stderr, 'Skipping hidden file "' + fullname + '" from inclusion in the emscripten virtual file system.' + else: + dstpath = os.path.join(rootpathdst, os.path.relpath(fullname, rootpathsrc)) # Convert source filename relative to root directory of target FS. + data_files.append({ 'srcpath': fullname, 'dstpath': dstpath, 'mode': mode }) for file_ in data_files: if os.path.isdir(file_['srcpath']): @@ -171,6 +203,8 @@ def add(arg, dirname, names): if file_['dstpath'].endswith('/'): # If user has submitted a directory name as the destination but omitted the destination filename, use the filename from source file file_['dstpath'] = file_['dstpath'] + os.path.basename(file_['srcpath']) if file_['dstpath'].startswith('./'): file_['dstpath'] = file_['dstpath'][2:] # remove redundant ./ prefix + if emcc_debug: + print >> sys.stderr, 'Packaging file "' + file_['srcpath'] + '" to VFS in path "' + file_['dstpath'] + '".' # Remove duplicates (can occur naively, for example preload dir/, preload dir/subdir/) seen = {} From 80e72facb82bb64a00098202afa6c03cc380b56e Mon Sep 17 00:00:00 2001 From: Anthony Pesch Date: Mon, 17 Jun 2013 10:40:00 -0700 Subject: [PATCH 06/51] fix weak alias for warn --- system/lib/libc.symbols | 2 +- system/lib/libc/gen/warn.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/lib/libc.symbols b/system/lib/libc.symbols index 70b210242cfbc..561f01c140191 100644 --- a/system/lib/libc.symbols +++ b/system/lib/libc.symbols @@ -77,5 +77,5 @@ W verrx W vwarn W vwarnx - W warn1 + W warn W warnx diff --git a/system/lib/libc/gen/warn.c b/system/lib/libc/gen/warn.c index c0803ab959e5e..c0dd2cd79adba 100644 --- a/system/lib/libc/gen/warn.c +++ b/system/lib/libc/gen/warn.c @@ -46,4 +46,4 @@ _warn(const char *fmt, ...) /* PRINTFLIKE1 */ void -warn(const char *fmt, ...) __attribute__((weak, alias("warn"))); +warn(const char *fmt, ...) __attribute__((weak, alias("_warn"))); From 56a3c81359687fd88bc27a0aca22c51f40e577c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 18 Jun 2013 00:18:27 +0300 Subject: [PATCH 07/51] Rename emcc_debug to DEBUG in tools/file_packager.py to be consistent. --- tools/file_packager.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/file_packager.py b/tools/file_packager.py index 1025207d65c04..99180b93c8d2f 100644 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -50,7 +50,7 @@ See the source for more details.''' sys.exit(0) -emcc_debug = os.environ.get('EMCC_DEBUG') +DEBUG = os.environ.get('EMCC_DEBUG') data_target = sys.argv[1] @@ -158,11 +158,11 @@ def has_hidden_attribute(filepath): return False try: - attrs = ctypes.windll.kernel32.GetFileAttributesW(unicode(filepath)) - assert attrs != -1 - result = bool(attrs & 2) + attrs = ctypes.windll.kernel32.GetFileAttributesW(unicode(filepath)) + assert attrs != -1 + result = bool(attrs & 2) except (AttributeError, AssertionError): - result = False + result = False return result # The packager should never preload/embed any directories that have a component starting with '.' in them, @@ -187,7 +187,7 @@ def add(arg, dirname, names): fullname = os.path.join(dirname, name) if not os.path.isdir(fullname): if should_ignore(fullname): - if emcc_debug: + if DEBUG: print >> sys.stderr, 'Skipping hidden file "' + fullname + '" from inclusion in the emscripten virtual file system.' else: dstpath = os.path.join(rootpathdst, os.path.relpath(fullname, rootpathsrc)) # Convert source filename relative to root directory of target FS. @@ -203,7 +203,7 @@ def add(arg, dirname, names): if file_['dstpath'].endswith('/'): # If user has submitted a directory name as the destination but omitted the destination filename, use the filename from source file file_['dstpath'] = file_['dstpath'] + os.path.basename(file_['srcpath']) if file_['dstpath'].startswith('./'): file_['dstpath'] = file_['dstpath'][2:] # remove redundant ./ prefix - if emcc_debug: + if DEBUG: print >> sys.stderr, 'Packaging file "' + file_['srcpath'] + '" to VFS in path "' + file_['dstpath'] + '".' # Remove duplicates (can occur naively, for example preload dir/, preload dir/subdir/) From f602fe5f6fcabc7e09ee474a21f45741835158bb Mon Sep 17 00:00:00 2001 From: David Barksdale Date: Thu, 6 Jun 2013 20:36:48 -0500 Subject: [PATCH 08/51] Fix LDBL_ constants in float.h. This fixes a bug compiling libunistring which checks these constants against sizeof(long double). --- system/include/bsd/float.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/system/include/bsd/float.h b/system/include/bsd/float.h index 7020cf9a30311..383e637c7af17 100644 --- a/system/include/bsd/float.h +++ b/system/include/bsd/float.h @@ -73,15 +73,15 @@ __END_DECLS #define DBL_MAX 1.7976931348623157E+308 #define DBL_MAX_10_EXP 308 -#define LDBL_MANT_DIG 64 -#define LDBL_EPSILON 1.08420217248550443401e-19L -#define LDBL_DIG 18 -#define LDBL_MIN_EXP (-16381) -#define LDBL_MIN 3.36210314311209350626e-4932L -#define LDBL_MIN_10_EXP (-4931) -#define LDBL_MAX_EXP 16384 -#define LDBL_MAX 1.18973149535723176502e+4932L -#define LDBL_MAX_10_EXP 4932 +#define LDBL_MANT_DIG DBL_MANT_DIG +#define LDBL_EPSILON DBL_EPSILON +#define LDBL_DIG DBL_DIG +#define LDBL_MIN_EXP DBL_MIN_EXP +#define LDBL_MIN DBL_MIN +#define LDBL_MIN_10_EXP DBL_MIN_10_EXP +#define LDBL_MAX_EXP DBL_MAX_EXP +#define LDBL_MAX DBL_MAX +#define LDBL_MAX_10_EXP DBL_MAX_10_EXP #if __ISO_C_VISIBLE >= 1999 #define DECIMAL_DIG 21 From 1326270ce8fc81825fa39d8db235bd3a47a9900d Mon Sep 17 00:00:00 2001 From: David Barksdale Date: Tue, 11 Jun 2013 20:37:13 -0500 Subject: [PATCH 09/51] Added test for float.h agreeing with sizeof. --- AUTHORS | 2 + tests/float+.c | 143 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/runner.py | 5 ++ 3 files changed, 150 insertions(+) create mode 100644 tests/float+.c diff --git a/AUTHORS b/AUTHORS index 9e9d5748acb4e..6dd9d53eb05bb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -83,6 +83,8 @@ a license to everyone to use it as detailed in LICENSE.) * Jez Ng * Marc Feeley (copyright owned by Mozilla Foundation) * Ludovic Perrine +* David Barksdale + diff --git a/tests/float+.c b/tests/float+.c new file mode 100644 index 0000000000000..eab0826294f40 --- /dev/null +++ b/tests/float+.c @@ -0,0 +1,143 @@ +/* Supplemental information about the floating-point formats. + Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. + Written by Bruno Haible , 2007. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#include +#include + +/* Number of bits in the mantissa of a floating-point number, including the + "hidden bit". */ +#if FLT_RADIX == 2 +# define FLT_MANT_BIT FLT_MANT_DIG +# define DBL_MANT_BIT DBL_MANT_DIG +# define LDBL_MANT_BIT LDBL_MANT_DIG +#elif FLT_RADIX == 4 +# define FLT_MANT_BIT (FLT_MANT_DIG * 2) +# define DBL_MANT_BIT (DBL_MANT_DIG * 2) +# define LDBL_MANT_BIT (LDBL_MANT_DIG * 2) +#elif FLT_RADIX == 16 +# define FLT_MANT_BIT (FLT_MANT_DIG * 4) +# define DBL_MANT_BIT (DBL_MANT_DIG * 4) +# define LDBL_MANT_BIT (LDBL_MANT_DIG * 4) +#endif + +/* Bit mask that can be used to mask the exponent, as an unsigned number. */ +#define FLT_EXP_MASK ((FLT_MAX_EXP - FLT_MIN_EXP) | 7) +#define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7) +#define LDBL_EXP_MASK ((LDBL_MAX_EXP - LDBL_MIN_EXP) | 7) + +/* Number of bits used for the exponent of a floating-point number, including + the exponent's sign. */ +#define FLT_EXP_BIT \ + (FLT_EXP_MASK < 0x100 ? 8 : \ + FLT_EXP_MASK < 0x200 ? 9 : \ + FLT_EXP_MASK < 0x400 ? 10 : \ + FLT_EXP_MASK < 0x800 ? 11 : \ + FLT_EXP_MASK < 0x1000 ? 12 : \ + FLT_EXP_MASK < 0x2000 ? 13 : \ + FLT_EXP_MASK < 0x4000 ? 14 : \ + FLT_EXP_MASK < 0x8000 ? 15 : \ + FLT_EXP_MASK < 0x10000 ? 16 : \ + FLT_EXP_MASK < 0x20000 ? 17 : \ + FLT_EXP_MASK < 0x40000 ? 18 : \ + FLT_EXP_MASK < 0x80000 ? 19 : \ + FLT_EXP_MASK < 0x100000 ? 20 : \ + FLT_EXP_MASK < 0x200000 ? 21 : \ + FLT_EXP_MASK < 0x400000 ? 22 : \ + FLT_EXP_MASK < 0x800000 ? 23 : \ + FLT_EXP_MASK < 0x1000000 ? 24 : \ + FLT_EXP_MASK < 0x2000000 ? 25 : \ + FLT_EXP_MASK < 0x4000000 ? 26 : \ + FLT_EXP_MASK < 0x8000000 ? 27 : \ + FLT_EXP_MASK < 0x10000000 ? 28 : \ + FLT_EXP_MASK < 0x20000000 ? 29 : \ + FLT_EXP_MASK < 0x40000000 ? 30 : \ + FLT_EXP_MASK <= 0x7fffffff ? 31 : \ + 32) +#define DBL_EXP_BIT \ + (DBL_EXP_MASK < 0x100 ? 8 : \ + DBL_EXP_MASK < 0x200 ? 9 : \ + DBL_EXP_MASK < 0x400 ? 10 : \ + DBL_EXP_MASK < 0x800 ? 11 : \ + DBL_EXP_MASK < 0x1000 ? 12 : \ + DBL_EXP_MASK < 0x2000 ? 13 : \ + DBL_EXP_MASK < 0x4000 ? 14 : \ + DBL_EXP_MASK < 0x8000 ? 15 : \ + DBL_EXP_MASK < 0x10000 ? 16 : \ + DBL_EXP_MASK < 0x20000 ? 17 : \ + DBL_EXP_MASK < 0x40000 ? 18 : \ + DBL_EXP_MASK < 0x80000 ? 19 : \ + DBL_EXP_MASK < 0x100000 ? 20 : \ + DBL_EXP_MASK < 0x200000 ? 21 : \ + DBL_EXP_MASK < 0x400000 ? 22 : \ + DBL_EXP_MASK < 0x800000 ? 23 : \ + DBL_EXP_MASK < 0x1000000 ? 24 : \ + DBL_EXP_MASK < 0x2000000 ? 25 : \ + DBL_EXP_MASK < 0x4000000 ? 26 : \ + DBL_EXP_MASK < 0x8000000 ? 27 : \ + DBL_EXP_MASK < 0x10000000 ? 28 : \ + DBL_EXP_MASK < 0x20000000 ? 29 : \ + DBL_EXP_MASK < 0x40000000 ? 30 : \ + DBL_EXP_MASK <= 0x7fffffff ? 31 : \ + 32) +#define LDBL_EXP_BIT \ + (LDBL_EXP_MASK < 0x100 ? 8 : \ + LDBL_EXP_MASK < 0x200 ? 9 : \ + LDBL_EXP_MASK < 0x400 ? 10 : \ + LDBL_EXP_MASK < 0x800 ? 11 : \ + LDBL_EXP_MASK < 0x1000 ? 12 : \ + LDBL_EXP_MASK < 0x2000 ? 13 : \ + LDBL_EXP_MASK < 0x4000 ? 14 : \ + LDBL_EXP_MASK < 0x8000 ? 15 : \ + LDBL_EXP_MASK < 0x10000 ? 16 : \ + LDBL_EXP_MASK < 0x20000 ? 17 : \ + LDBL_EXP_MASK < 0x40000 ? 18 : \ + LDBL_EXP_MASK < 0x80000 ? 19 : \ + LDBL_EXP_MASK < 0x100000 ? 20 : \ + LDBL_EXP_MASK < 0x200000 ? 21 : \ + LDBL_EXP_MASK < 0x400000 ? 22 : \ + LDBL_EXP_MASK < 0x800000 ? 23 : \ + LDBL_EXP_MASK < 0x1000000 ? 24 : \ + LDBL_EXP_MASK < 0x2000000 ? 25 : \ + LDBL_EXP_MASK < 0x4000000 ? 26 : \ + LDBL_EXP_MASK < 0x8000000 ? 27 : \ + LDBL_EXP_MASK < 0x10000000 ? 28 : \ + LDBL_EXP_MASK < 0x20000000 ? 29 : \ + LDBL_EXP_MASK < 0x40000000 ? 30 : \ + LDBL_EXP_MASK <= 0x7fffffff ? 31 : \ + 32) + +/* Number of bits used for a floating-point number: the mantissa (not + counting the "hidden bit", since it may or may not be explicit), the + exponent, and the sign. */ +#define FLT_TOTAL_BIT ((FLT_MANT_BIT - 1) + FLT_EXP_BIT + 1) +#define DBL_TOTAL_BIT ((DBL_MANT_BIT - 1) + DBL_EXP_BIT + 1) +#define LDBL_TOTAL_BIT ((LDBL_MANT_BIT - 1) + LDBL_EXP_BIT + 1) + +/* Number of bytes used for a floating-point number. + This can be smaller than the 'sizeof'. For example, on i386 systems, + 'long double' most often have LDBL_MANT_BIT = 64, LDBL_EXP_BIT = 16, hence + LDBL_TOTAL_BIT = 80 bits, i.e. 10 bytes of consecutive memory, but + sizeof (long double) = 12 or = 16. */ +#define SIZEOF_FLT ((FLT_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) +#define SIZEOF_DBL ((DBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) +#define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) + +/* Verify that SIZEOF_FLT <= sizeof (float) etc. */ +typedef int verify_sizeof_flt[2 * (SIZEOF_FLT <= sizeof (float)) - 1]; +typedef int verify_sizeof_dbl[2 * (SIZEOF_DBL <= sizeof (double)) - 1]; +typedef int verify_sizeof_ldbl[2 * (SIZEOF_LDBL <= sizeof (long double)) - 1]; diff --git a/tests/runner.py b/tests/runner.py index 04baf47ba3123..b974be78bd4c7 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -3982,6 +3982,11 @@ def test_sizeof(self): ''' self.do_run(src, '*2,2,5,8,8***8,8,5,8,8***7,2,6,990,7,2*', [], lambda x, err: x.replace('\n', '*')) + def test_float_h(self): + process = Popen([PYTHON, EMCC, path_from_root('tests', 'float+.c')], stdout=PIPE, stderr=PIPE) + process.communicate() + assert process.returncode is 0, 'float.h should agree with our system' + def test_emscripten_api(self): #if Settings.MICRO_OPTS or Settings.RELOOP or Building.LLVM_OPTS: return self.skip('FIXME') From a16f6f5f88cc3a94ecac720ffa01ccf2a4750a62 Mon Sep 17 00:00:00 2001 From: David Barksdale Date: Fri, 14 Jun 2013 23:25:16 -0500 Subject: [PATCH 10/51] Implement strnlen. --- src/library.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/library.js b/src/library.js index f958a436a9bac..151cf3e53706e 100644 --- a/src/library.js +++ b/src/library.js @@ -4657,6 +4657,14 @@ LibraryManager.library = { return 0; }, + strnlen: function(ptr, num) { + for (var i = 0; i < num; i++) { + if ({{{ makeGetValue('ptr', 0, 'i8') }}} == 0) return i; + ptr++; + } + return num; + }, + strstr: function(ptr1, ptr2) { var check = 0, start; do { From c158595be87cdebfb90d5c1bc272673be9cc06e7 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 17 Jun 2013 17:27:41 -0700 Subject: [PATCH 11/51] improve inline js test --- tests/runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/runner.py b/tests/runner.py index f22fd86b930e9..7575d65126f2d 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -4023,7 +4023,7 @@ def test_inlinejs(self): double get() { double ret = 0; - __asm __volatile__("12/3.3":"=r"(ret)); + __asm __volatile__("Math.abs(-12/3.3)":"=r"(ret)); // write to a variable return ret; } From 83d1e40dc67587c0eee1a5103ee51cfc435aa91d Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Mon, 17 Jun 2013 18:00:44 -0700 Subject: [PATCH 12/51] Fix SDL color encoding. Little-endian + RGBA means that red is located at the lowest-order bits, not the highest. The hello_world_sdl test is now portable, because we no longer write to individual bytes. We also add a test for a completely blank screen, which should be black, not red. Closes #1287, #761, #765. --- src/library_sdl.js | 26 +++++++++++--------------- tests/hello_world_sdl.cpp | 8 +++----- tests/runner.py | 3 +++ tests/sdl_canvas_blank.c | 17 +++++++++++++++++ tests/sdl_canvas_blank.png | Bin 0 -> 914 bytes 5 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 tests/sdl_canvas_blank.c create mode 100644 tests/sdl_canvas_blank.png diff --git a/src/library_sdl.js b/src/library_sdl.js index 5aaddb3bf3519..356c974644ba7 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -242,7 +242,7 @@ var LibrarySDL = { }, translateColorToCSSRGBA: function(rgba) { - return 'rgba(' + ((rgba >> 24)&255) + ',' + ((rgba >> 16)&255) + ',' + ((rgba >> 8)&255) + ',' + ((rgba&255)/255) + ')'; + return 'rgba(' + (rgba&0xff) + ',' + (rgba>>8 & 0xff) + ',' + (rgba>>16 & 0xff) + ',' + (rgba>>>24)/0xff + ')'; }, translateRGBAToCSSRGBA: function(r, g, b, a) { @@ -250,7 +250,7 @@ var LibrarySDL = { }, translateRGBAToColor: function(r, g, b, a) { - return (r << 24) + (g << 16) + (b << 8) + a; + return r | g << 8 | b << 16 | a << 24; }, makeSurface: function(width, height, flags, usePageCanvas, source, rmask, gmask, bmask, amask) { @@ -819,7 +819,6 @@ var LibrarySDL = { if (surfData.isFlagSet(0x00200000 /* SDL_HWPALETTE */)) { SDL.copyIndexedColorData(surfData); } else if (!surfData.colors) { - var num = surfData.image.data.length; var data = surfData.image.data; var buffer = surfData.buffer; #if USE_TYPED_ARRAYS == 2 @@ -827,17 +826,14 @@ var LibrarySDL = { var src = buffer >> 2; var dst = 0; var isScreen = surf == SDL.screen; + var data32 = new Uint32Array(data.buffer); + var num = data32.length; while (dst < num) { - // TODO: access underlying data buffer and write in 32-bit chunks or more - var val = HEAP32[src]; // This is optimized. Instead, we could do {{{ makeGetValue('buffer', 'dst', 'i32') }}}; - data[dst ] = val & 0xff; - data[dst+1] = (val >> 8) & 0xff; - data[dst+2] = (val >> 16) & 0xff; - data[dst+3] = isScreen ? 0xff : ((val >> 24) & 0xff); - src++; - dst += 4; + // HEAP32[src++] is an optimization. Instead, we could do {{{ makeGetValue('buffer', 'dst', 'i32') }}}; + data32[dst++] = HEAP32[src++] | (isScreen ? 0xff000000 : 0); } #else + var num = surfData.image.data.length; for (var i = 0; i < num; i++) { // We may need to correct signs here. Potentially you can hardcode a write of 255 to alpha, say, and // the compiler may decide to write -1 in the llvm bitcode... @@ -1120,13 +1116,13 @@ var LibrarySDL = { }, SDL_MapRGB: function(fmt, r, g, b) { - // Canvas screens are always RGBA - return 0xff+((b&0xff)<<8)+((g&0xff)<<16)+((r&0xff)<<24) + // Canvas screens are always RGBA. We assume the machine is little-endian. + return r&0xff|(g&0xff)<<8|(b&0xff)<<16|0xff000000; }, SDL_MapRGBA: function(fmt, r, g, b, a) { - // Canvas screens are always RGBA - return (a&0xff)+((b&0xff)<<8)+((g&0xff)<<16)+((r&0xff)<<24) + // Canvas screens are always RGBA. We assume the machine is little-endian. + return r&0xff|(g&0xff)<<8|(b&0xff)<<16|(a&0xff)<<24; }, SDL_GetAppState: function() { diff --git a/tests/hello_world_sdl.cpp b/tests/hello_world_sdl.cpp index b640199538f6e..eeaad0cd1c410 100644 --- a/tests/hello_world_sdl.cpp +++ b/tests/hello_world_sdl.cpp @@ -2,7 +2,7 @@ #include -int main() { +extern "C" int main(int argc, char** argv) { printf("hello, world!\n"); SDL_Init(SDL_INIT_VIDEO); @@ -11,10 +11,8 @@ int main() { if (SDL_MUSTLOCK(screen)) SDL_LockSurface(screen); for (int i = 0; i < 256; i++) { for (int j = 0; j < 256; j++) { - *((char*)screen->pixels + i*256*4 + j*4 + 0) = i; - *((char*)screen->pixels + i*256*4 + j*4 + 1) = j; - *((char*)screen->pixels + i*256*4 + j*4 + 2) = 255-i; - *((char*)screen->pixels + i*256*4 + j*4 + 3) = (i+j)%255; // actually ignored, since this is to the screen + // alpha component is actually ignored, since this is to the screen + *((Uint32*)screen->pixels + i * 256 + j) = SDL_MapRGBA(screen->format, i, j, 255-i, (i+j) % 255); } } if (SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen); diff --git a/tests/runner.py b/tests/runner.py index e74344795f476..4b8a3010d676a 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -12735,6 +12735,9 @@ def test_cubegeom_pre2_vao2(self): def test_cube_explosion(self): self.btest('cube_explosion.c', expected=['667220544', '-1543354600', '-1485258415']) + def test_sdl_canvas_blank(self): + self.btest('sdl_canvas_blank.c', reference='sdl_canvas_blank.png') + def test_sdl_canvas_palette(self): self.btest('sdl_canvas_palette.c', reference='sdl_canvas_palette.png') diff --git a/tests/sdl_canvas_blank.c b/tests/sdl_canvas_blank.c new file mode 100644 index 0000000000000..0e7607a660619 --- /dev/null +++ b/tests/sdl_canvas_blank.c @@ -0,0 +1,17 @@ +#include +#include + + +int main() { + SDL_Init(SDL_INIT_VIDEO); + SDL_Surface *screen = SDL_SetVideoMode(256, 256, 32, SDL_SWSURFACE); + + if (SDL_MUSTLOCK(screen)) SDL_LockSurface(screen); + if (SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen); + SDL_Flip(screen); + + SDL_Quit(); + + return 0; +} + diff --git a/tests/sdl_canvas_blank.png b/tests/sdl_canvas_blank.png new file mode 100644 index 0000000000000000000000000000000000000000..dc5a4a269bcbbde2a7d0bf28f5706ad91a29da2b GIT binary patch literal 914 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|GzJFdNKY5Xkcv5P&nYr881S%c z{GMMmxo`pF!<*aK=S*d9@RMV(s$_WagmJ;-QO;->jHUx(^Fl|>5&^zXpSS$k2h3{> Mp00i_>zopr0E_=X@c;k- literal 0 HcmV?d00001 From 4537de04414b3356628ec79fb919d0c10d5eff17 Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Mon, 17 Jun 2013 18:13:38 -0700 Subject: [PATCH 13/51] Make browser tests nicer to run. A bunch of misc changes, including fixing compile-time warnings, and muting the Python server request log. --- tests/runner.py | 6 ++++++ tests/sdl_image_prepare_data.c | 4 +++- tests/sdl_maprgba.c | 1 - 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/runner.py b/tests/runner.py index 4b8a3010d676a..d055924012a88 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -11452,6 +11452,9 @@ def do_GET(s): result = q.get() s.wfile.write(result) s.wfile.close() + def log_request(code=0, size=0): + # don't log; too noisy + pass httpd = BaseHTTPServer.HTTPServer(('localhost', 9999), TestServerHandler) httpd.serve_forever() # test runner will kill us @@ -11472,6 +11475,9 @@ def do_GET(s): s.send_response(500) s.send_header("Content-type", "text/html") s.end_headers() + def log_request(code=0, size=0): + # don't log; too noisy + pass os.chdir(dir) httpd = BaseHTTPServer.HTTPServer(('localhost', 8888), TestServerHandler) httpd.serve_forever() # test runner will kill us diff --git a/tests/sdl_image_prepare_data.c b/tests/sdl_image_prepare_data.c index 87e33399164be..d45a2e6078419 100644 --- a/tests/sdl_image_prepare_data.c +++ b/tests/sdl_image_prepare_data.c @@ -1,4 +1,6 @@ #include +#include +#include #include #include #include @@ -43,7 +45,7 @@ void ready(void *arg, const char *fileName) { testImage(seenName); - free(seenName); // As the API docs say, we are responsible for freeing the 'fake' names we are given + free((void*)seenName); // As the API docs say, we are responsible for freeing the 'fake' names we are given SDL_Flip(screen); } diff --git a/tests/sdl_maprgba.c b/tests/sdl_maprgba.c index c87c752487244..4b5c0026c59f2 100644 --- a/tests/sdl_maprgba.c +++ b/tests/sdl_maprgba.c @@ -1,6 +1,5 @@ #include #include -#include int main() { Uint32 c; From a04b53740e3de7cc8b4c4b9d6fd9fd903c0f97aa Mon Sep 17 00:00:00 2001 From: manny/MADE Date: Sun, 16 Jun 2013 16:39:09 +0200 Subject: [PATCH 14/51] BUGFIX: lists cannot be llvm_va_copy was broken, didn't copy list offset --- src/library.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/library.js b/src/library.js index 151cf3e53706e..d6e6879b1deb6 100644 --- a/src/library.js +++ b/src/library.js @@ -5008,6 +5008,7 @@ LibraryManager.library = { llvm_va_copy: function(ppdest, ppsrc) { {{{ makeCopyValues('ppdest', 'ppsrc', Runtime.QUANTUM_SIZE, 'null', null, 1) }}}; + {{{ makeCopyValues('(ppdest+4)', '(ppsrc+4)', Runtime.QUANTUM_SIZE, 'null', null, 1) }}}; /* Alternate implementation that copies the actual DATA; it assumes the va_list is prefixed by its size var psrc = IHEAP[ppsrc]-1; var num = IHEAP[psrc]; // right before the data, is the number of (flattened) values From f015eb3da85cae5fd3cad36a17c6633b6cb5ca7b Mon Sep 17 00:00:00 2001 From: manny/MADE Date: Mon, 17 Jun 2013 14:03:11 +0200 Subject: [PATCH 15/51] IMPROVED: va_list offset is not hardcoded, added comments --- src/jsifier.js | 6 ++++-- src/library.js | 16 ++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/jsifier.js b/src/jsifier.js index faef88d514a01..88b9d9f6fc7f9 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -1310,8 +1310,10 @@ function JSify(data, functionsOnly, givenFunctions) { assert(TARGET_LE32); var ident = item.value.ident; var move = Runtime.STACK_ALIGN; - return '(tempInt=' + makeGetValue(ident, 4, '*') + ',' + - makeSetValue(ident, 4, 'tempInt + ' + move, '*') + ',' + + + // store current list offset in tempInt, advance list offset by STACK_ALIGN, return list entry stored at tempInt + return '(tempInt=' + makeGetValue(ident, Runtime.QUANTUM_SIZE, '*') + ',' + + makeSetValue(ident, Runtime.QUANTUM_SIZE, 'tempInt + ' + move, '*') + ',' + makeGetValue(makeGetValue(ident, 0, '*'), 'tempInt', item.type) + ')'; }); diff --git a/src/library.js b/src/library.js index d6e6879b1deb6..33dcbd5f219b3 100644 --- a/src/library.js +++ b/src/library.js @@ -4999,23 +4999,19 @@ LibraryManager.library = { return makeSetValue(ptr, 0, 'varrp', 'void*'); #endif #if TARGET_LE32 - // 4-word structure: start, current offset - return makeSetValue(ptr, 0, 'varrp', 'void*') + ';' + makeSetValue(ptr, 4, 0, 'void*'); + // 2-word structure: struct { void* start; void* currentOffset; } + return makeSetValue(ptr, 0, 'varrp', 'void*') + ';' + makeSetValue(ptr, Runtime.QUANTUM_SIZE, 0, 'void*'); #endif }, llvm_va_end: function() {}, llvm_va_copy: function(ppdest, ppsrc) { + // copy the list start {{{ makeCopyValues('ppdest', 'ppsrc', Runtime.QUANTUM_SIZE, 'null', null, 1) }}}; - {{{ makeCopyValues('(ppdest+4)', '(ppsrc+4)', Runtime.QUANTUM_SIZE, 'null', null, 1) }}}; - /* Alternate implementation that copies the actual DATA; it assumes the va_list is prefixed by its size - var psrc = IHEAP[ppsrc]-1; - var num = IHEAP[psrc]; // right before the data, is the number of (flattened) values - var pdest = _malloc(num+1); - _memcpy(pdest, psrc, num+1); - IHEAP[ppdest] = pdest+1; - */ + + // copy the list's current offset (will be advanced with each call to va_arg) + {{{ makeCopyValues('(ppdest+'+Runtime.QUANTUM_SIZE+')', '(ppsrc+'+Runtime.QUANTUM_SIZE+')', Runtime.QUANTUM_SIZE, 'null', null, 1) }}}; }, llvm_bswap_i16: function(x) { From 4f15e867c0f45e3eb95bac3552156914cf623072 Mon Sep 17 00:00:00 2001 From: manny/MADE Date: Mon, 17 Jun 2013 15:46:21 +0200 Subject: [PATCH 16/51] ADDED: test to ensure va_lists work properly when copied, reinitialized etc. --- tests/runner.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/tests/runner.py b/tests/runner.py index 7575d65126f2d..cb850e487301c 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -4310,6 +4310,54 @@ def test_varargs(self): puts(d); va_end(v); } + + void varargs_listoffsets_list_evaluate(int count, va_list ap, int vaIteration) + { + while(count > 0) + { + const char* string = va_arg(ap, const char*); + printf("%s", string); + count--; + } + + printf("\\n"); + } + + void varags_listoffsets_list_copy(int count, va_list ap, int iteration) + { + va_list ap_copy; + va_copy(ap_copy, ap); + varargs_listoffsets_list_evaluate(count, ap_copy, iteration); + va_end(ap_copy); + } + + void varargs_listoffsets_args(int type, int count, ...) + { + va_list ap; + va_start(ap, count); + + // evaluate a copied list + varags_listoffsets_list_copy(count, ap, 1); + varags_listoffsets_list_copy(count, ap, 2); + varags_listoffsets_list_copy(count, ap, 3); + varags_listoffsets_list_copy(count, ap, 4); + + varargs_listoffsets_list_evaluate(count, ap, 1); + + // NOTE: we expect this test to fail, so we will check the stdout for ..... + varargs_listoffsets_list_evaluate(count, ap, 2); + + // NOTE: this test has to work again, as we restart the list + va_end(ap); + va_start(ap, count); + varargs_listoffsets_list_evaluate(count, ap, 3); + va_end(ap); + } + + void varargs_listoffsets_main() + { + varargs_listoffsets_args(0, 5, "abc", "def", "ghi", "jkl", "mno", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""); + } #define GETMAX(pref, type) \ type getMax##pref(int num, ...) \ @@ -4342,10 +4390,14 @@ def test_varargs(self): void (*vfp)(const char *s, ...) = argc == 1211 ? NULL : vary; vfp("*vfp:%d,%d*", 22, 199); + // ensure lists work properly when copied, reinited etc. + varargs_listoffsets_main(); + return 0; } ''' - self.do_run(src, '*cheez: 0+24*\n*cheez: 0+24*\n*albeit*\n*albeit*\nQ85*\nmaxxi:21*\nmaxxD:22.10*\n*vfp:22,199*\n*vfp:22,199*\n') + self.do_run(src, '*cheez: 0+24*\n*cheez: 0+24*\n*albeit*\n*albeit*\nQ85*\nmaxxi:21*\nmaxxD:22.10*\n*vfp:22,199*\n*vfp:22,199*\n'+ + 'abcdefghijklmno\nabcdefghijklmno\nabcdefghijklmno\nabcdefghijklmno\nabcdefghijklmno\n\nabcdefghijklmno\n') def test_varargs_byval(self): if Settings.USE_TYPED_ARRAYS != 2: return self.skip('FIXME: Add support for this') From dceafa222a1227c07c99353edebd7eecb94c1196 Mon Sep 17 00:00:00 2001 From: manny/MADE Date: Mon, 17 Jun 2013 16:40:03 +0200 Subject: [PATCH 17/51] CHANGED: added myself to AUTHORS --- AUTHORS | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 6dd9d53eb05bb..27206740d479c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -84,7 +84,4 @@ a license to everyone to use it as detailed in LICENSE.) * Marc Feeley (copyright owned by Mozilla Foundation) * Ludovic Perrine * David Barksdale - - - - +* Manfred Manik Nerurkar (copyright owned by MADE, GmbH) From 268a7f5ae065c6be0e0b63d3e4b7e36dd674cd4b Mon Sep 17 00:00:00 2001 From: manny/MADE Date: Mon, 17 Jun 2013 17:03:43 +0200 Subject: [PATCH 18/51] CHANGED: using spaces instead of tabs to match project codestyle --- tests/runner.py | 77 ++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/tests/runner.py b/tests/runner.py index cb850e487301c..69662132291f2 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -4312,47 +4312,46 @@ def test_varargs(self): } void varargs_listoffsets_list_evaluate(int count, va_list ap, int vaIteration) - { - while(count > 0) - { - const char* string = va_arg(ap, const char*); - printf("%s", string); - count--; - } - - printf("\\n"); - } - + { + while(count > 0) + { + const char* string = va_arg(ap, const char*); + printf("%s", string); + count--; + } + printf("\\n"); + } + void varags_listoffsets_list_copy(int count, va_list ap, int iteration) { - va_list ap_copy; - va_copy(ap_copy, ap); - varargs_listoffsets_list_evaluate(count, ap_copy, iteration); - va_end(ap_copy); - } - - void varargs_listoffsets_args(int type, int count, ...) - { - va_list ap; - va_start(ap, count); - - // evaluate a copied list - varags_listoffsets_list_copy(count, ap, 1); - varags_listoffsets_list_copy(count, ap, 2); - varags_listoffsets_list_copy(count, ap, 3); - varags_listoffsets_list_copy(count, ap, 4); - - varargs_listoffsets_list_evaluate(count, ap, 1); - - // NOTE: we expect this test to fail, so we will check the stdout for ..... - varargs_listoffsets_list_evaluate(count, ap, 2); - - // NOTE: this test has to work again, as we restart the list - va_end(ap); - va_start(ap, count); - varargs_listoffsets_list_evaluate(count, ap, 3); - va_end(ap); - } + va_list ap_copy; + va_copy(ap_copy, ap); + varargs_listoffsets_list_evaluate(count, ap_copy, iteration); + va_end(ap_copy); + } + + void varargs_listoffsets_args(int type, int count, ...) + { + va_list ap; + va_start(ap, count); + + // evaluate a copied list + varags_listoffsets_list_copy(count, ap, 1); + varags_listoffsets_list_copy(count, ap, 2); + varags_listoffsets_list_copy(count, ap, 3); + varags_listoffsets_list_copy(count, ap, 4); + + varargs_listoffsets_list_evaluate(count, ap, 1); + + // NOTE: we expect this test to fail, so we will check the stdout for ..... + varargs_listoffsets_list_evaluate(count, ap, 2); + + // NOTE: this test has to work again, as we restart the list + va_end(ap); + va_start(ap, count); + varargs_listoffsets_list_evaluate(count, ap, 3); + va_end(ap); + } void varargs_listoffsets_main() { From 819ccd4914ba1f5db1c21829cb4615886829f26e Mon Sep 17 00:00:00 2001 From: manny/MADE Date: Mon, 17 Jun 2013 17:08:17 +0200 Subject: [PATCH 19/51] CHANGED: using spaces instead of tabs to match project codestyle --- tests/runner.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/runner.py b/tests/runner.py index 69662132291f2..b4f07014a1d41 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -4355,7 +4355,7 @@ def test_varargs(self): void varargs_listoffsets_main() { - varargs_listoffsets_args(0, 5, "abc", "def", "ghi", "jkl", "mno", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""); + varargs_listoffsets_args(0, 5, "abc", "def", "ghi", "jkl", "mno", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""); } #define GETMAX(pref, type) \ @@ -4389,8 +4389,8 @@ def test_varargs(self): void (*vfp)(const char *s, ...) = argc == 1211 ? NULL : vary; vfp("*vfp:%d,%d*", 22, 199); - // ensure lists work properly when copied, reinited etc. - varargs_listoffsets_main(); + // ensure lists work properly when copied, reinited etc. + varargs_listoffsets_main(); return 0; } From 939bda64f5f205c3c6ba774e5a69966053fa6222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Tue, 18 Jun 2013 17:19:45 +0300 Subject: [PATCH 20/51] Fix bug in file_packager.py introduced in my recent pull request that caused all files to be skipped from being packaged if the path contains a relative '.' in its path name (e.g. './path/etc'). --- tools/file_packager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/file_packager.py b/tools/file_packager.py index 99180b93c8d2f..a65de3f714a3b 100644 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -174,7 +174,7 @@ def should_ignore(filename): components = filename.replace('\\\\', '/').replace('\\', '/').split('/') for c in components: - if c.startswith('.'): + if c.startswith('.') and c != '.' and c != '..': return True return False From 695207758b0dccdcacb63eb04ee4eb372841529d Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 18 Jun 2013 10:47:53 -0700 Subject: [PATCH 21/51] do not use EMCC_OPTIMIZE_NORMALLY in relooper --- tools/shared.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/shared.py b/tools/shared.py index b212a9cc8234d..0cfe30ad28a3a 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -1288,6 +1288,9 @@ def ensure_relooper(relooper): emcc_debug = os.environ.get('EMCC_DEBUG') if emcc_debug: del os.environ['EMCC_DEBUG'] + emcc_optimize_normally = os.environ.get('EMCC_OPTIMIZE_NORMALLY') + if emcc_optimize_normally: del os.environ['EMCC_OPTIMIZE_NORMALLY'] + def make(opt_level): raw = relooper + '.raw.js' Building.emcc(os.path.join('relooper', 'Relooper.cpp'), ['-I' + os.path.join('relooper'), '--post-js', @@ -1318,6 +1321,7 @@ def make(opt_level): finally: os.chdir(curr) if emcc_debug: os.environ['EMCC_DEBUG'] = emcc_debug + if emcc_optimize_normally: os.environ['EMCC_OPTIMIZE_NORMALLY'] = emcc_optimize_normally if not ok: logging.error('bootstrapping relooper failed. You may need to manually create relooper.js by compiling it, see src/relooper/emscripten') 1/0 From a15b0d50618241a345d13ae4d939bfc53178a01d Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 18 Jun 2013 15:21:14 -0700 Subject: [PATCH 22/51] do not do full Browser.init() in workers, just the minimum we need --- src/library_browser.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/library_browser.js b/src/library_browser.js index 9800fedf355a9..925b64e24a5da 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -47,8 +47,11 @@ mergeInto(LibraryManager.library, { workers: [], init: function() { - if (Browser.initted) return; + if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; // needs to exist even in workers + + if (Browser.initted || ENVIRONMENT_IS_WORKER) return; Browser.initted = true; + try { new Blob(); Browser.hasBlobConstructor = true; @@ -79,8 +82,6 @@ mergeInto(LibraryManager.library, { }[name.substr(name.lastIndexOf('.')+1)]; } - if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; - var imagePlugin = {}; imagePlugin['canHandle'] = function(name) { return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/.exec(name); From f144ebdbd829a9223e50d7858d7ba79e43030875 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 18 Jun 2013 18:18:37 -0700 Subject: [PATCH 23/51] add wip inlinejs2 test --- tests/runner.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/runner.py b/tests/runner.py index 7575d65126f2d..72c9afd16dc80 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -4036,6 +4036,39 @@ def test_inlinejs(self): self.do_run(src, 'Inline JS is very cool\n3.64') + def zzztest_inlinejs2(self): + if Settings.ASM_JS: return self.skip('asm does not support random code, TODO: something that works in asm') + src = r''' + #include + + double get() { + double ret = 0; + __asm __volatile__("Math.abs(-12/3.3)":"=r"(ret)); // write to a variable + return ret; + } + + int mix(int x, int y) { + int ret; + asm("Math.pow(2, %0+%1+1)" : "=r"(ret) : "r"(x), "r"(y)); // read and write + return ret; + } + + void mult() { + asm("var $_$1 = Math.abs(-100); $_$1 *= 2;"); // multiline + asm __volatile__("Module.print($_$1); Module.print('\n')"); + } + + int main(int argc, char **argv) { + asm("Module.print('Inline JS is very cool')"); + printf("%.2f\n", get()); + printf("%d\n", mix(argc, argc/2)); + mult(); + return 0; + } + ''' + + self.do_run(src, 'Inline JS is very cool\n3.64\nwaka\nzakai\n') + def test_memorygrowth(self): if Settings.USE_TYPED_ARRAYS == 0: return self.skip('memory growth is only supported with typed arrays') if Settings.ASM_JS: return self.skip('asm does not support memory growth yet') From 52279fa9b201bb151c12d8b494d421c39abad67d Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 18 Jun 2013 18:51:52 -0700 Subject: [PATCH 24/51] disable new test_varargs in x86 (requires le32 now) --- tests/runner.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/runner.py b/tests/runner.py index 830b2e18f06fe..6519bf0513a95 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -4311,6 +4311,7 @@ def test_pack(self): def test_varargs(self): if Settings.QUANTUM_SIZE == 1: return self.skip('FIXME: Add support for this') + if not self.is_le32(): return self.skip('we do not support all varargs stuff without le32') src = ''' #include From 384ef1a600be168a49994fb59159bf5b120c53c0 Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Tue, 18 Jun 2013 18:52:48 -0700 Subject: [PATCH 25/51] Update minimum node version. --- tests/runner.py | 2 +- tools/shared.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/runner.py b/tests/runner.py index 7575d65126f2d..fa9ceda41b6d7 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -13819,7 +13819,7 @@ def test_node(self): try: os.environ['EM_IGNORE_SANITY'] = '1' - for version, succeed in [(('v0.6.6'), False), (('v0.6.7'), False), (('v0.6.8'), True), (('v0.6.9'), True), (('v0.7.1'), True), (('v0.7.9'), True), (('v0.8.7'), True), (('v0.8.9'), True), ('cheez', False)]: + for version, succeed in [('v0.7.9', False), ('v0.8.0', True), ('v0.8.1', True), ('cheez', False)]: f = open(path_from_root('tests', 'fake', 'nodejs'), 'w') f.write('#!/bin/sh\n') f.write('''if [ $1 = "--version" ]; then diff --git a/tools/shared.py b/tools/shared.py index 0cfe30ad28a3a..c16c91154af85 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -273,7 +273,7 @@ def check_llvm_version(): except Exception, e: logging.warning('Could not verify LLVM version: %s' % str(e)) -EXPECTED_NODE_VERSION = (0,6,8) +EXPECTED_NODE_VERSION = (0,8,0) def check_node_version(): try: From 40d935ea64557828ab49a87de7924ad529faff16 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 18 Jun 2013 18:55:58 -0700 Subject: [PATCH 26/51] reduce error to warning on having no functions --- emscripten.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emscripten.py b/emscripten.py index d831285589007..c9a5eb59747d2 100755 --- a/emscripten.py +++ b/emscripten.py @@ -128,7 +128,7 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, if DEBUG: print >> sys.stderr, ' emscript: split took %s seconds' % (time.time() - t) if len(funcs) == 0: - raise RuntimeError('No functions to process. Make sure you prevented LLVM from eliminating them as dead (use EXPORTED_FUNCTIONS if necessary, see the FAQ)') + print >> sys.stderr, 'No functions to process. Make sure you prevented LLVM from eliminating them as dead (use EXPORTED_FUNCTIONS if necessary, see the FAQ)' #if DEBUG: # print >> sys.stderr, '========= pre ================\n' From 3963031492acab163f8fa440aaf50661d954506b Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 18 Jun 2013 19:03:57 -0700 Subject: [PATCH 27/51] post messages to crunch worker with a new arrayBuffer, to avoid copying an underlying one --- tools/file_packager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/file_packager.py b/tools/file_packager.py index a65de3f714a3b..cc030f595c6b5 100644 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -236,7 +236,7 @@ def was_seen(name): function requestDecrunch(filename, data, callback) { decrunchWorker.postMessage({ filename: filename, - data: data, + data: new Uint8Array(data), callbackID: decrunchCallbacks.length }); decrunchCallbacks.push(callback); From 9ee4ca4af663921dace9aa6bcdd206825adf145e Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Tue, 18 Jun 2013 19:13:29 -0700 Subject: [PATCH 28/51] Missed out making some tests portable. --- tests/sdl_canvas.c | 2 +- tests/sdl_canvas_twice.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/sdl_canvas.c b/tests/sdl_canvas.c index 97cd13480b61d..10044ff4fa08e 100644 --- a/tests/sdl_canvas.c +++ b/tests/sdl_canvas.c @@ -38,7 +38,7 @@ int main(int argc, char **argv) { // fill stuff SDL_Rect rect = { 200, 200, 175, 125 }; - SDL_FillRect(screen, &rect, 0x2222ffff); + SDL_FillRect(screen, &rect, SDL_MapRGBA(screen->format, 0x22, 0x22, 0xff, 0xff)); SDL_Flip(screen); diff --git a/tests/sdl_canvas_twice.c b/tests/sdl_canvas_twice.c index 6c6e480290a36..28a7a01c0f9a3 100644 --- a/tests/sdl_canvas_twice.c +++ b/tests/sdl_canvas_twice.c @@ -8,12 +8,12 @@ int main(int argc, char **argv) { SDL_Init(SDL_INIT_VIDEO); SDL_Surface *screen = SDL_SetVideoMode(40, 40, 32, SDL_SWSURFACE); - SDL_FillRect(screen, NULL, 0xff0000ff); + SDL_FillRect(screen, NULL, SDL_MapRGBA(screen->format, 0xff, 0, 0, 0xff)); SDL_LockSurface(screen); *((int*)screen->pixels + 95) = 0; SDL_UnlockSurface(screen); - SDL_FillRect(screen, NULL, 0x00ff00ff); // wipe out previous pixel and fill + SDL_FillRect(screen, NULL, SDL_MapRGBA(screen->format, 0, 0xff, 0, 0xff)); // wipe out previous pixel and fill SDL_LockSurface(screen); *((int*)screen->pixels + 205) = 0; SDL_UnlockSurface(screen); From c669e63b4da7de25f1622748c40331f7ce282feb Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Tue, 18 Jun 2013 01:16:56 -0700 Subject: [PATCH 29/51] Make more tests use btest(). Also fix test_glgears_deriv so that it actually animates its gears. --- tests/hello_world_gles_deriv.c | 7 ++- tests/runner.py | 91 +++++++++++++++++----------------- 2 files changed, 51 insertions(+), 47 deletions(-) diff --git a/tests/hello_world_gles_deriv.c b/tests/hello_world_gles_deriv.c index 2e0f0664a4652..c5354d4e80f4b 100644 --- a/tests/hello_world_gles_deriv.c +++ b/tests/hello_world_gles_deriv.c @@ -46,8 +46,13 @@ #include #include #include +#ifdef __APPLE__ +#include +#include +#else #include #include +#endif #ifndef HAVE_BUILTIN_SINCOS #include "sincos.h" @@ -716,7 +721,7 @@ main(int argc, char *argv[]) glutCreateWindow("es2gears"); /* Set up glut callback functions */ - gears_idle(); + glutIdleFunc (gears_idle); glutReshapeFunc(gears_reshape); glutDisplayFunc(gears_draw); glutSpecialFunc(gears_special); diff --git a/tests/runner.py b/tests/runner.py index 553c7b4daaeec..30fdf70682984 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -11694,9 +11694,8 @@ def reftest(self, expected): def test_html(self): # test HTML generation. - self.reftest(path_from_root('tests', 'htmltest.png')) - output = Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_sdl.cpp'), '-o', 'something.html', '--pre-js', 'reftest.js']).communicate() - self.run_browser('something.html', 'You should see "hello, world!" and a colored cube.', '/report_result?0') + self.btest('hello_world_sdl.cpp', reference='htmltest.png', + message='You should see "hello, world!" and a colored cube.') def build_native_lzma(self): lzma_native = path_from_root('third_party', 'lzma.js', 'lzma-native') @@ -12424,52 +12423,52 @@ def test_sdl_gl_read(self): def test_sdl_ogl(self): shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png')) - self.reftest(path_from_root('tests', 'screenshot-gray-purple.png')) - Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_ogl.c'), '-O2', '--minify', '0', '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png', '-s', 'GL_TESTING=1']).communicate() - self.run_browser('something.html', 'You should see an image with gray at the top.', '/report_result?0') + self.btest('sdl_ogl.c', reference='screenshot-gray-purple.png', + args=['-O2', '--minify', '0', '--preload-file', 'screenshot.png'], + message='You should see an image with gray at the top.') def test_sdl_ogl_defaultmatrixmode(self): shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png')) - self.reftest(path_from_root('tests', 'screenshot-gray-purple.png')) - Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_ogl_defaultMatrixMode.c'), '--minify', '0', '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png', '-s', 'GL_TESTING=1']).communicate() - self.run_browser('something.html', 'You should see an image with gray at the top.', '/report_result?0') + self.btest('sdl_ogl_defaultMatrixMode.c', reference='screenshot-gray-purple.png', + args=['--minify', '0', '--preload-file', 'screenshot.png'], + message='You should see an image with gray at the top.') def test_sdl_ogl_p(self): # Immediate mode with pointers shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png')) - self.reftest(path_from_root('tests', 'screenshot-gray.png')) - Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_ogl_p.c'), '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png', '-s', 'GL_TESTING=1']).communicate() - self.run_browser('something.html', 'You should see an image with gray at the top.', '/report_result?0') + self.btest('sdl_ogl_p.c', reference='screenshot-gray.png', + args=['--preload-file', 'screenshot.png'], + message='You should see an image with gray at the top.') def test_sdl_fog_simple(self): shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png')) - self.reftest(path_from_root('tests', 'screenshot-fog-simple.png')) - Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_fog_simple.c'), '-O2', '--minify', '0', '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png', '-s', 'GL_TESTING=1']).communicate() - self.run_browser('something.html', 'You should see an image with fog.', '/report_result?0') + self.btest('sdl_fog_simple.c', reference='screenshot-fog-simple.png', + args=['-O2', '--minify', '0', '--preload-file', 'screenshot.png'], + message='You should see an image with fog.') def test_sdl_fog_negative(self): shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png')) - self.reftest(path_from_root('tests', 'screenshot-fog-negative.png')) - Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_fog_negative.c'), '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png', '-s', 'GL_TESTING=1']).communicate() - self.run_browser('something.html', 'You should see an image with fog.', '/report_result?0') + self.btest('sdl_fog_negative.c', reference='screenshot-fog-negative.png', + args=['--preload-file', 'screenshot.png'], + message='You should see an image with fog.') def test_sdl_fog_density(self): shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png')) - self.reftest(path_from_root('tests', 'screenshot-fog-density.png')) - Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_fog_density.c'), '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png', '-s', 'GL_TESTING=1']).communicate() - self.run_browser('something.html', 'You should see an image with fog.', '/report_result?0') + self.btest('sdl_fog_density.c', reference='screenshot-fog-density.png', + args=['--preload-file', 'screenshot.png'], + message='You should see an image with fog.') def test_sdl_fog_exp2(self): shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png')) - self.reftest(path_from_root('tests', 'screenshot-fog-exp2.png')) - Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_fog_exp2.c'), '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png', '-s', 'GL_TESTING=1']).communicate() - self.run_browser('something.html', 'You should see an image with fog.', '/report_result?0') + self.btest('sdl_fog_exp2.c', reference='screenshot-fog-exp2.png', + args=['--preload-file', 'screenshot.png'], + message='You should see an image with fog.') def test_sdl_fog_linear(self): shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png')) - self.reftest(path_from_root('tests', 'screenshot-fog-linear.png')) - Popen([PYTHON, EMCC, path_from_root('tests', 'sdl_fog_linear.c'), '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png', '-s', 'GL_TESTING=1']).communicate() - self.run_browser('something.html', 'You should see an image with fog.', '/report_result?0') + self.btest('sdl_fog_linear.c', reference='screenshot-fog-linear.png', + args=['--preload-file', 'screenshot.png'], + message='You should see an image with fog.') def test_openal_playback(self): shutil.copyfile(path_from_root('tests', 'sounds', 'audio.wav'), os.path.join(self.get_dir(), 'audio.wav')) @@ -12633,10 +12632,9 @@ def do_GET(s): server.terminate() def test_glgears(self): - self.reftest(path_from_root('tests', 'gears.png')) - Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_gles.c'), '-o', 'something.html', - '-DHAVE_BUILTIN_SINCOS', '--pre-js', 'reftest.js', '-s', 'GL_TESTING=1']).communicate() - self.run_browser('something.html', 'You should see animating gears.', '/report_result?0') + self.btest('hello_world_gles.c', reference='gears.png', + args=['-DHAVE_BUILTIN_SINCOS'], outfile='something.html', + message='You should see animating gears.') def test_glgears_animation(self): es2_suffix = ['', '_full', '_full_944'] @@ -12657,12 +12655,11 @@ def test_fulles2_sdlproc(self): self.btest('full_es2_sdlproc.c', '1', args=['-s', 'GL_TESTING=1', '-DHAVE_BUILTIN_SINCOS', '-s', 'FULL_ES2=1']) def test_glgears_deriv(self): - self.reftest(path_from_root('tests', 'gears.png')) - Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_gles_deriv.c'), '-o', 'something.html', '-s', 'GL_TESTING=1', - '-DHAVE_BUILTIN_SINCOS', '--pre-js', 'reftest.js']).communicate() - self.run_browser('something.html', 'You should see animating gears.', '/report_result?0') - src = open('something.html').read() - assert 'gl-matrix' not in src, 'Should not include glMatrix when not needed' + self.btest('hello_world_gles_deriv.c', reference='gears.png', + args=['-DHAVE_BUILTIN_SINCOS'], outfile='something.html', + message='You should see animating gears.') + with open('something.html') as f: + assert 'gl-matrix' not in f.read(), 'Should not include glMatrix when not needed' def test_glbook(self): programs = self.get_library('glbook', [ @@ -12688,26 +12685,28 @@ def book_path(*pathelems): shutil.copyfile(book_path('Chapter_13', 'ParticleSystem', 'smoke.tga'), os.path.join(self.get_dir(), 'smoke.tga')) args = ['--preload-file', 'smoke.tga', '-O2'] # test optimizations and closure here as well for more coverage - self.reftest(book_path(basename.replace('.bc', '.png'))) - Popen([PYTHON, EMCC, program, '-o', 'program.html', '--pre-js', 'reftest.js', '-s', 'GL_TESTING=1'] + args).communicate() - self.run_browser('program.html', '', '/report_result?0') + self.btest(program, + reference=book_path(basename.replace('.bc', '.png')), args=args) - def btest(self, filename, expected=None, reference=None, reference_slack=0, args=[]): # TODO: use in all other tests + def btest(self, filename, expected=None, reference=None, reference_slack=0, + args=[], outfile='test.html', message='.'): # TODO: use in all other tests + filepath = path_from_root('tests', filename) + temp_filepath = os.path.join(self.get_dir(), os.path.basename(filename)) if not reference: if '\n' in filename: # if we are provided the source and not a path, use that src = filename filename = 'main.cpp' else: - src = open(path_from_root('tests', filename)).read() - open(os.path.join(self.get_dir(), filename), 'w').write(self.with_report_result(src)) + with open(filepath) as f: f.read() + with open(temp_filepath, 'w') as f: f.write(self.with_report_result(src)) else: expected = [str(i) for i in range(0, reference_slack+1)] - shutil.copyfile(path_from_root('tests', filename), os.path.join(self.get_dir(), os.path.basename(filename))) + shutil.copyfile(filepath, temp_filepath) self.reftest(path_from_root('tests', reference)) args = args + ['--pre-js', 'reftest.js', '-s', 'GL_TESTING=1'] - Popen([PYTHON, EMCC, os.path.join(self.get_dir(), os.path.basename(filename)), '-o', 'test.html'] + args).communicate() + Popen([PYTHON, EMCC, temp_filepath, '-o', outfile] + args).communicate() if type(expected) is str: expected = [expected] - self.run_browser('test.html', '.', ['/report_result?' + e for e in expected]) + self.run_browser(outfile, message, ['/report_result?' + e for e in expected]) def test_gles2_emulation(self): shutil.copyfile(path_from_root('tests', 'glbook', 'Chapter_10', 'MultiTexture', 'basemap.tga'), self.in_dir('basemap.tga')) From a830513d444b0d78060e9cdc675d5f31e73b9ed6 Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Tue, 18 Jun 2013 02:00:11 -0700 Subject: [PATCH 30/51] Actually exit test runner when browser tests are done. Using __del__ didn't work for me with Python 2.7.2 on OS X. --- tests/runner.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/runner.py b/tests/runner.py index 30fdf70682984..a008b8429a0e7 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -11583,7 +11583,8 @@ def __init__(self, *args, **kwargs): print '[Browser harness server on process %d]' % browser.harness_server.pid webbrowser.open_new('http://localhost:9999/run_harness') - def __del__(self): + @classmethod + def tearDownClass(cls): if not hasattr(browser, 'harness_server'): return browser.harness_server.terminate() From db017ea554622bac445729e43139710a5f52604b Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Tue, 18 Jun 2013 02:14:50 -0700 Subject: [PATCH 31/51] Favor explicit parameter passing over string manipulation. --- tests/runner.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/runner.py b/tests/runner.py index a008b8429a0e7..610a39f690ff7 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -14204,8 +14204,6 @@ def test_jcache(self): raise Exception('Test runner is confused: ' + str(sys.argv)) if __name__ == '__main__': - sys.argv = [sys.argv[0]] + ['-v'] + sys.argv[1:] # Verbose output by default - # Sanity checks total_engines = len(JS_ENGINES) @@ -14237,5 +14235,4 @@ def test_jcache(self): # Go - unittest.main() - + unittest.main(verbosity=2) From e4f8c8184058d8d621d8f3ac007a0d1a55980832 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 19 Jun 2013 11:31:10 -0700 Subject: [PATCH 32/51] keep coercions on heap accesses and function calls, but fully optimize them otherwise --- tools/js-optimizer.js | 67 ++-- tools/test-js-optimizer-asm-pre-output.js | 360 +++++++++++++++++++++- tools/test-js-optimizer-asm-pre.js | 357 ++++++++++++++++++++- 3 files changed, 754 insertions(+), 30 deletions(-) diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 07317e0a22d69..7f186252f8997 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -429,7 +429,14 @@ function simplifyExpressionsPre(ast) { // 'useful' mathops already |0 anyhow. function simplifyBitops(ast) { - var SAFE_BINARY_OPS = set('+', '-', '*'); // division is unsafe as it creates non-ints in JS; mod is unsafe as signs matter so we can't remove |0's + var SAFE_BINARY_OPS; + if (asm) { + SAFE_BINARY_OPS = set('+', '-'); // division is unsafe as it creates non-ints in JS; mod is unsafe as signs matter so we can't remove |0's; mul does not nest with +,- in asm + } else { + SAFE_BINARY_OPS = set('+', '-', '*'); + } + var COERCION_REQUIRING_OPS = set('call', 'sub', 'unary-prefix'); // ops that in asm must be coerced + var COERCION_REQUIRING_BINARIES = set('*', '/', '%'); // binary ops that in asm must be coerced var ZERO = ['num', 0]; var rerun = true; while (rerun) { @@ -438,24 +445,39 @@ function simplifyExpressionsPre(ast) { if (type == 'binary' && node[1] == '|') { if (node[2][0] == 'num' && node[3][0] == 'num') { return ['num', node[2][1] | node[3][1]]; - } else if (jsonCompare(node[2], ZERO) || jsonCompare(node[3], ZERO)) { - // We might be able to remove this correction - for (var i = stack.length-1; i >= 0; i--) { - if (stack[i] == 1) { - // we will replace ourselves with the non-zero side. Recursively process that node. - var result = jsonCompare(node[2], ZERO) ? node[3] : node[2], other; - // replace node in-place - node.length = result.length; - for (var j = 0; j < result.length; j++) { - node[j] = result[j]; - } - rerun = true; - return process(result, result[0], stack); - } else if (stack[i] == -1) { - break; // Too bad, we can't - } else if (asm) { - break; // we must keep a coercion right on top of a heap access in asm mode + } + var go = false; + if (jsonCompare(node[2], ZERO)) { + // canonicalize order + var temp = node[3]; + node[3] = node[2]; + node[2] = temp; + go = true; + } else if (jsonCompare(node[3], ZERO)) { + go = true; + } + if (!go) { + stack.push(1); + return; + } + // We might be able to remove this correction + for (var i = stack.length-1; i >= 0; i--) { + if (stack[i] == 1) { + if (asm && stack[stack.length-1] != 1) { + if (node[2][0] in COERCION_REQUIRING_OPS || + (node[2][0] == 'binary' && node[2][1] in COERCION_REQUIRING_BINARIES)) break; } + // we will replace ourselves with the non-zero side. Recursively process that node. + var result = jsonCompare(node[2], ZERO) ? node[3] : node[2], other; + // replace node in-place + node.length = result.length; + for (var j = 0; j < result.length; j++) { + node[j] = result[j]; + } + rerun = true; + return process(result, result[0], stack); + } else if (stack[i] == -1) { + break; // Too bad, we can't } } stack.push(1); // From here on up, no need for this kind of correction, it's done at the top @@ -707,18 +729,11 @@ function simplifyExpressionsPre(ast) { } function asmOpts(fun) { - // 1. Add final returns when necessary - // 2. Remove unneeded coercions on function calls that have no targets (eliminator removed it) + // Add final returns when necessary var returnType = null; traverse(fun, function(node, type) { if (type == 'return' && node[1]) { returnType = detectAsmCoercion(node[1]); - } else if (type == 'stat') { - var inner = node[1]; - if ((inner[0] == 'binary' && inner[1] in ASSOCIATIVE_BINARIES && inner[2][0] == 'call' && inner[3][0] == 'num') || - (inner[0] == 'unary-prefix' && inner[1] == '+' && inner[2][0] == 'call')) { - node[1] = inner[2]; - } } }); // Add a final return if one is missing. diff --git a/tools/test-js-optimizer-asm-pre-output.js b/tools/test-js-optimizer-asm-pre-output.js index 25d521abb93f4..903de1f9b8922 100644 --- a/tools/test-js-optimizer-asm-pre-output.js +++ b/tools/test-js-optimizer-asm-pre-output.js @@ -6,9 +6,15 @@ function a() { f(8); HEAP[1024] = 5; HEAP[1024] = 5; - whee(12, 13); - whee(12, 13); + whee(12, 13) | 0; + +whee(12, 13); f((g = t(), g + g | 0) | 0); + f() | 0; + f((h() | 0) + 5 | 0); + f(x + y + z | 0); + +f(); + f(+(+h() + 5)); + $140 = $p_3_i + (-$mantSize_0_i | 0) | 0; } function b($this, $__n) { $this = $this | 0; @@ -34,7 +40,7 @@ function b($this, $__n) { $23 = HEAP32[($this + 4 & 16777215) >> 2] | 0; } if (($14 - $23 | 0) >>> 0 < $__n >>> 0) { - __ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEjjjjjj($this, $14, ($__n - $14 | 0) + $23 | 0, $23, $23); + __ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEjjjjjj($this, $14, $__n - $14 + $23 | 0, $23, $23); $30 = HEAP8[$4 & 16777215] | 0; } else { $30 = $13; @@ -161,4 +167,352 @@ function boxx($this, $aabb, $xf, $childIndex) { HEAPF32[$51 + 4 >> 2] = $_sroa_0_0_insert_insert$1; return; } +function _main($argc, $argv) { + $argc = $argc | 0; + $argv = $argv | 0; + var $def_i21 = 0, $def_i = 0, $world = 0, $bd = 0, $shape = 0, $shape1 = 0, $bd2 = 0, $result = 0, $6 = 0, $WARMUP_0 = 0, $14 = 0, $15 = 0, $17 = 0, $i_09_i_i = 0, $j_08_i_i = 0, $34 = 0, $j_1_i_i = 0, $38 = 0, $46 = 0, $48 = 0, $50 = 0, $54 = 0, $i_05_i_i_i = 0, $56 = 0, $62 = 0, $_lcssa_i_i_i = 0, $87 = 0, $96 = 0, $97 = 0, $98 = 0, $112 = 0, $115 = 0, $116 = 0, $118 = 0, $121 = 0, $126 = 0, $135 = 0, $137 = 0, $174 = 0, $176 = 0, $177 = 0, $178 = 0, $179 = 0, $180 = 0, $181 = 0, $182 = 0, $183 = 0, $185 = 0, $186 = 0, $188 = 0, $189 = 0, $190 = 0, $191 = 0, $192 = 0, $193 = 0, $194 = 0, $195 = 0, $196 = 0, $i_057 = 0, $x_sroa_0_0_load303656 = +0, $x_sroa_1_4_load313755 = +0, $j_052 = 0, $y_sroa_0_0_load283451 = +0, $y_sroa_1_4_load293550 = +0, $y_sroa_0_0_insert_insert$1 = +0, $205 = 0, $208 = 0, $209 = 0, $213 = 0, $223 = 0, $236 = 0, $i3_042 = 0, $241 = 0, $242 = 0, $243 = 0, $i4_038 = 0, $245 = 0, $260 = +0, $_0 = 0, label = 0, __stackBase__ = 0; + __stackBase__ = STACKTOP; + STACKTOP = STACKTOP + 103416 | 0; + $def_i21 = __stackBase__ | 0; + $def_i = __stackBase__ + 32 | 0; + $world = __stackBase__ + 64 | 0; + $bd = __stackBase__ + 103096 | 0; + $shape = __stackBase__ + 103152 | 0; + $shape1 = __stackBase__ + 103200 | 0; + $bd2 = __stackBase__ + 103352 | 0; + $result = __stackBase__ + 103408 | 0; + do { + if (($argc | 0) > 1) { + $6 = HEAP8[HEAP32[$argv + 4 >> 2] | 0] | 0; + if (($6 | 0) == 49) { + HEAP32[2414] = 35; + $WARMUP_0 = 5; + break; + } else if (($6 | 0) == 50) { + HEAP32[2414] = 161; + $WARMUP_0 = 32; + break; + } else if (($6 | 0) == 51) { + label = 43; + break; + } else if (($6 | 0) == 52) { + HEAP32[2414] = 2331; + $WARMUP_0 = 320; + break; + } else if (($6 | 0) == 53) { + HEAP32[2414] = 5661; + $WARMUP_0 = 640; + break; + } else if (($6 | 0) == 48) { + $_0 = 0; + STACKTOP = __stackBase__; + return $_0 | 0; + } else { + _printf(3512, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $6 - 48, tempInt) | 0) | 0; + $_0 = -1; + STACKTOP = __stackBase__; + return $_0 | 0; + } + } else { + label = 43; + } + } while (0); + if ((label | 0) == 43) { + HEAP32[2414] = 333; + $WARMUP_0 = 64; + } + $14 = $world | 0; + $15 = $world + 8 | 0; + HEAP32[$15 >> 2] = 128; + HEAP32[$world + 4 >> 2] = 0; + $17 = _malloc(1024) | 0; + HEAP32[$world >> 2] = $17; + _memset($17 | 0, 0, HEAP32[$15 >> 2] << 3 | 0); + _memset($world + 12 | 0, 0, 56); + $j_08_i_i = 0; + $i_09_i_i = 1; + while (1) { + if (!(($j_08_i_i | 0) < 14)) { + label = 49; + break; + } + if (($i_09_i_i | 0) > (HEAP32[9600 + ($j_08_i_i << 2) >> 2] | 0)) { + $34 = $j_08_i_i + 1 | 0; + HEAP8[$i_09_i_i + 8952 | 0] = $34 & 255; + $j_1_i_i = $34; + } else { + HEAP8[$i_09_i_i + 8952 | 0] = $j_08_i_i & 255; + $j_1_i_i = $j_08_i_i; + } + $38 = $i_09_i_i + 1 | 0; + if (($38 | 0) < 641) { + $j_08_i_i = $j_1_i_i; + $i_09_i_i = $38; + } else { + break; + } + } + if ((label | 0) == 49) { + ___assert_func(3248, 73, 6448, 3360); + return 0; + } + HEAP32[$world + 102468 >> 2] = 0; + HEAP32[$world + 102472 >> 2] = 0; + HEAP32[$world + 102476 >> 2] = 0; + HEAP32[$world + 102864 >> 2] = 0; + HEAP32[$world + 102872 >> 2] = -1; + $46 = $world + 102884 | 0; + HEAP32[$46 >> 2] = 16; + HEAP32[$world + 102880 >> 2] = 0; + $48 = _malloc(576) | 0; + $50 = $world + 102876 | 0; + HEAP32[$50 >> 2] = $48; + _memset($48 | 0, 0, (HEAP32[$46 >> 2] | 0) * 36 & -1 | 0); + $54 = (HEAP32[$46 >> 2] | 0) - 1 | 0; + if (($54 | 0) > 0) { + $i_05_i_i_i = 0; + while (1) { + $56 = $i_05_i_i_i + 1 | 0; + HEAP32[(HEAP32[$50 >> 2] | 0) + ($i_05_i_i_i * 36 & -1) + 20 >> 2] = $56; + HEAP32[(HEAP32[$50 >> 2] | 0) + ($i_05_i_i_i * 36 & -1) + 32 >> 2] = -1; + $62 = (HEAP32[$46 >> 2] | 0) - 1 | 0; + if (($56 | 0) < ($62 | 0)) { + $i_05_i_i_i = $56; + } else { + $_lcssa_i_i_i = $62; + break; + } + } + } else { + $_lcssa_i_i_i = $54; + } + HEAP32[(HEAP32[$50 >> 2] | 0) + ($_lcssa_i_i_i * 36 & -1) + 20 >> 2] = -1; + HEAP32[(HEAP32[$50 >> 2] | 0) + (((HEAP32[$46 >> 2] | 0) - 1 | 0) * 36 & -1) + 32 >> 2] = -1; + _memset($world + 102888 | 0, 0, 16); + HEAP32[$world + 102920 >> 2] = 16; + HEAP32[$world + 102924 >> 2] = 0; + HEAP32[$world + 102916 >> 2] = _malloc(192) | 0; + HEAP32[$world + 102908 >> 2] = 16; + HEAP32[$world + 102912 >> 2] = 0; + HEAP32[$world + 102904 >> 2] = _malloc(64) | 0; + HEAP32[$world + 102932 >> 2] = 0; + HEAP32[$world + 102936 >> 2] = 0; + HEAP32[$world + 102940 >> 2] = 104; + HEAP32[$world + 102944 >> 2] = 96; + $87 = $world + 102948 | 0; + HEAP32[$world + 102980 >> 2] = 0; + HEAP32[$world + 102984 >> 2] = 0; + _memset($87 | 0, 0, 20); + HEAP8[$world + 102992 | 0] = 1; + HEAP8[$world + 102993 | 0] = 1; + HEAP8[$world + 102994 | 0] = 0; + HEAP8[$world + 102995 | 0] = 1; + $96 = $world + 102976 | 0; + HEAP8[$96] = 1; + $97 = $world + 102968 | 0; + HEAP32[$97 >> 2] = 0; + HEAP32[$97 + 4 >> 2] = -1054867456; + $98 = $world + 102868 | 0; + HEAP32[$98 >> 2] = 4; + HEAPF32[$world + 102988 >> 2] = +0; + HEAP32[$87 >> 2] = $14; + _memset($world + 102996 | 0, 0, 32); + HEAP8[$96] = 0; + HEAP32[$bd + 44 >> 2] = 0; + _memset($bd + 4 | 0, 0, 32); + HEAP8[$bd + 36 | 0] = 1; + HEAP8[$bd + 37 | 0] = 1; + HEAP8[$bd + 38 | 0] = 0; + HEAP8[$bd + 39 | 0] = 0; + HEAP32[$bd >> 2] = 0; + HEAP8[$bd + 40 | 0] = 1; + HEAPF32[$bd + 48 >> 2] = +1; + $112 = __ZN16b2BlockAllocator8AllocateEi($14, 152) | 0; + if (($112 | 0) == 0) { + $116 = 0; + } else { + $115 = $112; + __ZN6b2BodyC2EPK9b2BodyDefP7b2World($115, $bd, $world); + $116 = $115; + } + HEAP32[$116 + 92 >> 2] = 0; + $118 = $world + 102952 | 0; + HEAP32[$116 + 96 >> 2] = HEAP32[$118 >> 2]; + $121 = HEAP32[$118 >> 2] | 0; + if (!(($121 | 0) == 0)) { + HEAP32[$121 + 92 >> 2] = $116; + } + HEAP32[$118 >> 2] = $116; + $126 = $world + 102960 | 0; + HEAP32[$126 >> 2] = (HEAP32[$126 >> 2] | 0) + 1; + HEAP32[$shape >> 2] = 8016; + HEAP32[$shape + 4 >> 2] = 1; + HEAPF32[$shape + 8 >> 2] = +.009999999776482582; + _memset($shape + 28 | 0, 0, 18); + $135 = $shape + 12 | 0; + HEAP32[$135 >> 2] = -1038090240; + HEAP32[$135 + 4 >> 2] = 0; + $137 = $shape + 20 | 0; + HEAP32[$137 >> 2] = 1109393408; + HEAP32[$137 + 4 >> 2] = 0; + HEAP8[$shape + 44 | 0] = 0; + HEAP8[$shape + 45 | 0] = 0; + HEAP16[$def_i + 22 >> 1] = 1; + HEAP16[$def_i + 24 >> 1] = -1; + HEAP16[$def_i + 26 >> 1] = 0; + HEAP32[$def_i + 4 >> 2] = 0; + HEAPF32[$def_i + 8 >> 2] = +.20000000298023224; + HEAPF32[$def_i + 12 >> 2] = +0; + HEAP8[$def_i + 20 | 0] = 0; + HEAP32[$def_i >> 2] = $shape; + HEAPF32[$def_i + 16 >> 2] = +0; + __ZN6b2Body13CreateFixtureEPK12b2FixtureDef($116, $def_i); + HEAP32[$shape1 >> 2] = 7968; + HEAP32[$shape1 + 4 >> 2] = 2; + HEAPF32[$shape1 + 8 >> 2] = +.009999999776482582; + HEAP32[$shape1 + 148 >> 2] = 4; + HEAPF32[$shape1 + 20 >> 2] = +-.5; + HEAPF32[$shape1 + 24 >> 2] = +-.5; + HEAPF32[$shape1 + 28 >> 2] = +.5; + HEAPF32[$shape1 + 32 >> 2] = +-.5; + HEAPF32[$shape1 + 36 >> 2] = +.5; + HEAPF32[$shape1 + 40 >> 2] = +.5; + HEAPF32[$shape1 + 44 >> 2] = +-.5; + HEAPF32[$shape1 + 48 >> 2] = +.5; + HEAPF32[$shape1 + 84 >> 2] = +0; + HEAPF32[$shape1 + 88 >> 2] = +-1; + HEAPF32[$shape1 + 92 >> 2] = +1; + HEAPF32[$shape1 + 96 >> 2] = +0; + HEAPF32[$shape1 + 100 >> 2] = +0; + HEAPF32[$shape1 + 104 >> 2] = +1; + HEAPF32[$shape1 + 108 >> 2] = +-1; + HEAPF32[$shape1 + 112 >> 2] = +0; + HEAPF32[$shape1 + 12 >> 2] = +0; + HEAPF32[$shape1 + 16 >> 2] = +0; + $174 = $bd2 + 44 | 0; + $176 = $bd2 + 36 | 0; + $177 = $bd2 + 4 | 0; + $178 = $bd2 + 37 | 0; + $179 = $bd2 + 38 | 0; + $180 = $bd2 + 39 | 0; + $181 = $bd2 | 0; + $182 = $bd2 + 40 | 0; + $183 = $bd2 + 48 | 0; + $185 = $bd2 + 4 | 0; + $186 = $shape1 | 0; + $188 = $def_i21 + 22 | 0; + $189 = $def_i21 + 24 | 0; + $190 = $def_i21 + 26 | 0; + $191 = $def_i21 | 0; + $192 = $def_i21 + 4 | 0; + $193 = $def_i21 + 8 | 0; + $194 = $def_i21 + 12 | 0; + $195 = $def_i21 + 16 | 0; + $196 = $def_i21 + 20 | 0; + $x_sroa_1_4_load313755 = +.75; + $x_sroa_0_0_load303656 = +-7; + $i_057 = 0; + L82 : while (1) { + $y_sroa_1_4_load293550 = $x_sroa_1_4_load313755; + $y_sroa_0_0_load283451 = $x_sroa_0_0_load303656; + $j_052 = $i_057; + while (1) { + HEAP32[$174 >> 2] = 0; + _memset($177 | 0, 0, 32); + HEAP8[$176] = 1; + HEAP8[$178] = 1; + HEAP8[$179] = 0; + HEAP8[$180] = 0; + HEAP8[$182] = 1; + HEAPF32[$183 >> 2] = +1; + HEAP32[$181 >> 2] = 2; + $y_sroa_0_0_insert_insert$1 = +$y_sroa_1_4_load293550; + HEAPF32[$185 >> 2] = $y_sroa_0_0_load283451; + HEAPF32[$185 + 4 >> 2] = $y_sroa_0_0_insert_insert$1; + if (!((HEAP32[$98 >> 2] & 2 | 0) == 0)) { + label = 65; + break L82; + } + $205 = __ZN16b2BlockAllocator8AllocateEi($14, 152) | 0; + if (($205 | 0) == 0) { + $209 = 0; + } else { + $208 = $205; + __ZN6b2BodyC2EPK9b2BodyDefP7b2World($208, $bd2, $world); + $209 = $208; + } + HEAP32[$209 + 92 >> 2] = 0; + HEAP32[$209 + 96 >> 2] = HEAP32[$118 >> 2]; + $213 = HEAP32[$118 >> 2] | 0; + if (!(($213 | 0) == 0)) { + HEAP32[$213 + 92 >> 2] = $209; + } + HEAP32[$118 >> 2] = $209; + HEAP32[$126 >> 2] = (HEAP32[$126 >> 2] | 0) + 1; + HEAP16[$188 >> 1] = 1; + HEAP16[$189 >> 1] = -1; + HEAP16[$190 >> 1] = 0; + HEAP32[$192 >> 2] = 0; + HEAPF32[$193 >> 2] = +.20000000298023224; + HEAPF32[$194 >> 2] = +0; + HEAP8[$196] = 0; + HEAP32[$191 >> 2] = $186; + HEAPF32[$195 >> 2] = +5; + __ZN6b2Body13CreateFixtureEPK12b2FixtureDef($209, $def_i21); + $223 = $j_052 + 1 | 0; + if (($223 | 0) < 40) { + $y_sroa_1_4_load293550 = $y_sroa_1_4_load293550 + +0; + $y_sroa_0_0_load283451 = $y_sroa_0_0_load283451 + 1.125; + $j_052 = $223; + } else { + break; + } + } + $236 = $i_057 + 1 | 0; + if (($236 | 0) < 40) { + $x_sroa_1_4_load313755 = $x_sroa_1_4_load313755 + +1; + $x_sroa_0_0_load303656 = $x_sroa_0_0_load303656 + +.5625; + $i_057 = $236; + } else { + $i3_042 = 0; + break; + } + } + if ((label | 0) == 65) { + ___assert_func(112, 109, 5328, 2520); + return 0; + } + while (1) { + __ZN7b2World4StepEfii($world); + $i3_042 = $i3_042 + 1 | 0; + if (($i3_042 | 0) >= ($WARMUP_0 | 0)) { + break; + } + } + $241 = HEAP32[2414] | 0; + $242 = _llvm_stacksave() | 0; + $243 = STACKTOP; + STACKTOP = STACKTOP + ($241 * 4 & -1) | 0; + STACKTOP = STACKTOP + 7 >> 3 << 3; + if (($241 | 0) > 0) { + $i4_038 = 0; + while (1) { + $245 = _clock() | 0; + __ZN7b2World4StepEfii($world); + HEAP32[$243 + ($i4_038 << 2) >> 2] = (_clock() | 0) - $245; + $i4_038 = $i4_038 + 1 | 0; + if (($i4_038 | 0) >= (HEAP32[2414] | 0)) { + break; + } + } + } + __Z7measurePm($result, $243); + $260 = +HEAPF32[$result + 4 >> 2]; + _printf(3480, (tempInt = STACKTOP, STACKTOP = STACKTOP + 16 | 0, HEAPF64[tempInt >> 3] = +HEAPF32[$result >> 2], HEAPF64[tempInt + 8 >> 3] = $260, tempInt) | 0) | 0; + _llvm_stackrestore($242 | 0); + __ZN7b2WorldD2Ev($world); + $_0 = 0; + STACKTOP = __stackBase__; + return $_0 | 0; +} diff --git a/tools/test-js-optimizer-asm-pre.js b/tools/test-js-optimizer-asm-pre.js index 38487d2fff217..aac70b6004e7e 100644 --- a/tools/test-js-optimizer-asm-pre.js +++ b/tools/test-js-optimizer-asm-pre.js @@ -9,6 +9,13 @@ function a() { whee(12, 13) | 0; +whee(12, 13); f((g = t(), (g+g)|0)|0); + // always coerce function calls in asm + f() | 0; + f((h() | 0) + 5 | 0); + f(((x + y) | 0) + z | 0); + +f(); + f(+(+h() + 5)); + $140 = $p_3_i + (-$mantSize_0_i | 0) | 0; } function b($this, $__n) { $this = $this | 0; @@ -165,4 +172,352 @@ function boxx($this, $aabb, $xf, $childIndex) { HEAP32[$51 + 4 >> 2] = $_sroa_0_0_insert_insert$1; return; } -// EMSCRIPTEN_GENERATED_FUNCTIONS: ["a", "b", "rett", "ret2t", "retf", "i32_8", "tempDoublePtr", "boxx"] +function _main($argc, $argv) { + $argc = $argc | 0; + $argv = $argv | 0; + var $def_i21 = 0, $def_i = 0, $world = 0, $bd = 0, $shape = 0, $shape1 = 0, $bd2 = 0, $result = 0, $6 = 0, $WARMUP_0 = 0, $14 = 0, $15 = 0, $17 = 0, $i_09_i_i = 0, $j_08_i_i = 0, $34 = 0, $j_1_i_i = 0, $38 = 0, $46 = 0, $48 = 0, $50 = 0, $54 = 0, $i_05_i_i_i = 0, $56 = 0, $62 = 0, $_lcssa_i_i_i = 0, $87 = 0, $96 = 0, $97 = 0, $98 = 0, $112 = 0, $115 = 0, $116 = 0, $118 = 0, $121 = 0, $126 = 0, $135 = 0, $137 = 0, $174 = 0, $176 = 0, $177 = 0, $178 = 0, $179 = 0, $180 = 0, $181 = 0, $182 = 0, $183 = 0, $185 = 0, $186 = 0, $188 = 0, $189 = 0, $190 = 0, $191 = 0, $192 = 0, $193 = 0, $194 = 0, $195 = 0, $196 = 0, $i_057 = 0, $x_sroa_0_0_load303656 = +0, $x_sroa_1_4_load313755 = +0, $j_052 = 0, $y_sroa_0_0_load283451 = +0, $y_sroa_1_4_load293550 = +0, $y_sroa_0_0_insert_insert$1 = 0, $205 = 0, $208 = 0, $209 = 0, $213 = 0, $223 = 0, $236 = 0, $i3_042 = 0, $241 = 0, $242 = 0, $243 = 0, $i4_038 = 0, $245 = 0, $260 = +0, $_0 = 0, label = 0, __stackBase__ = 0; + __stackBase__ = STACKTOP; + STACKTOP = STACKTOP + 103416 | 0; + $def_i21 = __stackBase__ | 0; + $def_i = __stackBase__ + 32 | 0; + $world = __stackBase__ + 64 | 0; + $bd = __stackBase__ + 103096 | 0; + $shape = __stackBase__ + 103152 | 0; + $shape1 = __stackBase__ + 103200 | 0; + $bd2 = __stackBase__ + 103352 | 0; + $result = __stackBase__ + 103408 | 0; + do { + if (($argc | 0) > 1) { + $6 = (HEAP8[HEAP32[($argv + 4 | 0) >> 2] | 0] | 0) << 24 >> 24; + if (($6 | 0 | 0) == (49 | 0)) { + HEAP32[9656 >> 2] = 35; + $WARMUP_0 = 5; + break; + } else if (($6 | 0 | 0) == (50 | 0)) { + HEAP32[9656 >> 2] = 161; + $WARMUP_0 = 32; + break; + } else if (($6 | 0 | 0) == (51 | 0)) { + label = 43; + break; + } else if (($6 | 0 | 0) == (52 | 0)) { + HEAP32[9656 >> 2] = 2331; + $WARMUP_0 = 320; + break; + } else if (($6 | 0 | 0) == (53 | 0)) { + HEAP32[9656 >> 2] = 5661; + $WARMUP_0 = 640; + break; + } else if (($6 | 0 | 0) == (48 | 0)) { + $_0 = 0; + STACKTOP = __stackBase__; + return $_0 | 0; + } else { + _printf(3512 | 0 | 0, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[tempInt >> 2] = $6 - 48 | 0, tempInt) | 0) | 0; + $_0 = -1; + STACKTOP = __stackBase__; + return $_0 | 0; + } + } else { + label = 43; + } + } while (0); + if ((label | 0) == 43) { + HEAP32[9656 >> 2] = 333; + $WARMUP_0 = 64; + } + $14 = $world | 0; + $15 = $world + 8 | 0; + HEAP32[$15 >> 2] = 128; + HEAP32[($world + 4 | 0) >> 2] = 0; + $17 = _malloc(1024) | 0; + HEAP32[($world | 0) >> 2] = $17; + _memset($17 | 0 | 0, 0 | 0 | 0, (HEAP32[$15 >> 2] | 0) << 3 | 0 | 0); + _memset($world + 12 | 0 | 0 | 0, 0 | 0 | 0, 56 | 0 | 0); + $j_08_i_i = 0; + $i_09_i_i = 1; + while (1) { + if (!(($j_08_i_i | 0) < 14)) { + label = 49; + break; + } + if (($i_09_i_i | 0) > (HEAP32[(9600 + ($j_08_i_i << 2) | 0) >> 2] | 0 | 0)) { + $34 = $j_08_i_i + 1 | 0; + HEAP8[$i_09_i_i + 8952 | 0] = $34 & 255; + $j_1_i_i = $34; + } else { + HEAP8[$i_09_i_i + 8952 | 0] = $j_08_i_i & 255; + $j_1_i_i = $j_08_i_i; + } + $38 = $i_09_i_i + 1 | 0; + if (($38 | 0) < 641) { + $j_08_i_i = $j_1_i_i; + $i_09_i_i = $38; + } else { + break; + } + } + if ((label | 0) == 49) { + ___assert_func(3248 | 0 | 0, 73 | 0, 6448 | 0 | 0, 3360 | 0 | 0); + return 0 | 0; + } + HEAP32[($world + 102468 | 0) >> 2] = 0; + HEAP32[($world + 102472 | 0) >> 2] = 0; + HEAP32[($world + 102476 | 0) >> 2] = 0; + HEAP32[($world + 102864 | 0) >> 2] = 0; + HEAP32[($world + 102872 | 0) >> 2] = -1; + $46 = $world + 102884 | 0; + HEAP32[$46 >> 2] = 16; + HEAP32[($world + 102880 | 0) >> 2] = 0; + $48 = _malloc(576) | 0; + $50 = $world + 102876 | 0; + HEAP32[$50 >> 2] = $48; + _memset($48 | 0 | 0, 0 | 0 | 0, (HEAP32[$46 >> 2] | 0) * 36 & -1 | 0 | 0); + $54 = (HEAP32[$46 >> 2] | 0) - 1 | 0; + if (($54 | 0) > 0) { + $i_05_i_i_i = 0; + while (1) { + $56 = $i_05_i_i_i + 1 | 0; + HEAP32[((HEAP32[$50 >> 2] | 0) + ($i_05_i_i_i * 36 & -1) + 20 | 0) >> 2] = $56; + HEAP32[((HEAP32[$50 >> 2] | 0) + ($i_05_i_i_i * 36 & -1) + 32 | 0) >> 2] = -1; + $62 = (HEAP32[$46 >> 2] | 0) - 1 | 0; + if (($56 | 0) < ($62 | 0)) { + $i_05_i_i_i = $56; + } else { + $_lcssa_i_i_i = $62; + break; + } + } + } else { + $_lcssa_i_i_i = $54; + } + HEAP32[((HEAP32[$50 >> 2] | 0) + ($_lcssa_i_i_i * 36 & -1) + 20 | 0) >> 2] = -1; + HEAP32[((HEAP32[$50 >> 2] | 0) + (((HEAP32[$46 >> 2] | 0) - 1 | 0) * 36 & -1) + 32 | 0) >> 2] = -1; + _memset($world + 102888 | 0 | 0 | 0, 0 | 0 | 0, 16 | 0 | 0); + HEAP32[($world + 102920 | 0) >> 2] = 16; + HEAP32[($world + 102924 | 0) >> 2] = 0; + HEAP32[($world + 102916 | 0) >> 2] = _malloc(192) | 0; + HEAP32[($world + 102908 | 0) >> 2] = 16; + HEAP32[($world + 102912 | 0) >> 2] = 0; + HEAP32[($world + 102904 | 0) >> 2] = _malloc(64) | 0; + HEAP32[($world + 102932 | 0) >> 2] = 0; + HEAP32[($world + 102936 | 0) >> 2] = 0; + HEAP32[($world + 102940 | 0) >> 2] = 104; + HEAP32[($world + 102944 | 0) >> 2] = 96; + $87 = $world + 102948 | 0; + HEAP32[($world + 102980 | 0) >> 2] = 0; + HEAP32[($world + 102984 | 0) >> 2] = 0; + _memset($87 | 0 | 0, 0 | 0 | 0, 20 | 0 | 0); + HEAP8[$world + 102992 | 0] = 1; + HEAP8[$world + 102993 | 0] = 1; + HEAP8[$world + 102994 | 0] = 0; + HEAP8[$world + 102995 | 0] = 1; + $96 = $world + 102976 | 0; + HEAP8[$96] = 1; + $97 = $world + 102968 | 0; + HEAP32[($97 | 0) >> 2] = 0; + HEAP32[($97 + 4 | 0) >> 2] = -1054867456; + $98 = $world + 102868 | 0; + HEAP32[$98 >> 2] = 4; + HEAPF32[($world + 102988 | 0) >> 2] = +0; + HEAP32[$87 >> 2] = $14; + _memset($world + 102996 | 0 | 0 | 0, 0 | 0 | 0, 32 | 0 | 0); + HEAP8[$96] = 0; + HEAP32[($bd + 44 | 0) >> 2] = 0; + _memset($bd + 4 | 0 | 0 | 0, 0 | 0 | 0, 32 | 0 | 0); + HEAP8[$bd + 36 | 0] = 1; + HEAP8[$bd + 37 | 0] = 1; + HEAP8[$bd + 38 | 0] = 0; + HEAP8[$bd + 39 | 0] = 0; + HEAP32[($bd | 0) >> 2] = 0; + HEAP8[$bd + 40 | 0] = 1; + HEAPF32[($bd + 48 | 0) >> 2] = +1; + $112 = __ZN16b2BlockAllocator8AllocateEi($14, 152) | 0; + if (($112 | 0) == 0) { + $116 = 0; + } else { + $115 = $112; + __ZN6b2BodyC2EPK9b2BodyDefP7b2World($115, $bd, $world); + $116 = $115; + } + HEAP32[($116 + 92 | 0) >> 2] = 0; + $118 = $world + 102952 | 0; + HEAP32[($116 + 96 | 0) >> 2] = HEAP32[$118 >> 2] | 0; + $121 = HEAP32[$118 >> 2] | 0; + if (!(($121 | 0) == 0)) { + HEAP32[($121 + 92 | 0) >> 2] = $116; + } + HEAP32[$118 >> 2] = $116; + $126 = $world + 102960 | 0; + HEAP32[$126 >> 2] = (HEAP32[$126 >> 2] | 0) + 1 | 0; + HEAP32[($shape | 0) >> 2] = 8016 | 0; + HEAP32[($shape + 4 | 0) >> 2] = 1; + HEAPF32[($shape + 8 | 0) >> 2] = +.009999999776482582; + _memset($shape + 28 | 0 | 0 | 0, 0 | 0 | 0, 18 | 0 | 0); + $135 = $shape + 12 | 0; + HEAP32[($135 | 0) >> 2] = -1038090240; + HEAP32[($135 + 4 | 0) >> 2] = 0; + $137 = $shape + 20 | 0; + HEAP32[($137 | 0) >> 2] = 1109393408; + HEAP32[($137 + 4 | 0) >> 2] = 0; + HEAP8[$shape + 44 | 0] = 0; + HEAP8[$shape + 45 | 0] = 0; + HEAP16[($def_i + 22 | 0) >> 1] = 1; + HEAP16[($def_i + 24 | 0) >> 1] = -1; + HEAP16[($def_i + 26 | 0) >> 1] = 0; + HEAP32[($def_i + 4 | 0) >> 2] = 0; + HEAPF32[($def_i + 8 | 0) >> 2] = +.20000000298023224; + HEAPF32[($def_i + 12 | 0) >> 2] = +0; + HEAP8[$def_i + 20 | 0] = 0; + HEAP32[($def_i | 0) >> 2] = $shape | 0; + HEAPF32[($def_i + 16 | 0) >> 2] = +0; + __ZN6b2Body13CreateFixtureEPK12b2FixtureDef($116, $def_i); + HEAP32[($shape1 | 0) >> 2] = 7968 | 0; + HEAP32[($shape1 + 4 | 0) >> 2] = 2; + HEAPF32[($shape1 + 8 | 0) >> 2] = +.009999999776482582; + HEAP32[($shape1 + 148 | 0) >> 2] = 4; + HEAPF32[($shape1 + 20 | 0) >> 2] = +-.5; + HEAPF32[($shape1 + 24 | 0) >> 2] = +-.5; + HEAPF32[($shape1 + 28 | 0) >> 2] = +.5; + HEAPF32[($shape1 + 32 | 0) >> 2] = +-.5; + HEAPF32[($shape1 + 36 | 0) >> 2] = +.5; + HEAPF32[($shape1 + 40 | 0) >> 2] = +.5; + HEAPF32[($shape1 + 44 | 0) >> 2] = +-.5; + HEAPF32[($shape1 + 48 | 0) >> 2] = +.5; + HEAPF32[($shape1 + 84 | 0) >> 2] = +0; + HEAPF32[($shape1 + 88 | 0) >> 2] = +-1; + HEAPF32[($shape1 + 92 | 0) >> 2] = +1; + HEAPF32[($shape1 + 96 | 0) >> 2] = +0; + HEAPF32[($shape1 + 100 | 0) >> 2] = +0; + HEAPF32[($shape1 + 104 | 0) >> 2] = +1; + HEAPF32[($shape1 + 108 | 0) >> 2] = +-1; + HEAPF32[($shape1 + 112 | 0) >> 2] = +0; + HEAPF32[($shape1 + 12 | 0) >> 2] = +0; + HEAPF32[($shape1 + 16 | 0) >> 2] = +0; + $174 = $bd2 + 44 | 0; + $176 = $bd2 + 36 | 0; + $177 = $bd2 + 4 | 0; + $178 = $bd2 + 37 | 0; + $179 = $bd2 + 38 | 0; + $180 = $bd2 + 39 | 0; + $181 = $bd2 | 0; + $182 = $bd2 + 40 | 0; + $183 = $bd2 + 48 | 0; + $185 = $bd2 + 4 | 0; + $186 = $shape1 | 0; + $188 = $def_i21 + 22 | 0; + $189 = $def_i21 + 24 | 0; + $190 = $def_i21 + 26 | 0; + $191 = $def_i21 | 0; + $192 = $def_i21 + 4 | 0; + $193 = $def_i21 + 8 | 0; + $194 = $def_i21 + 12 | 0; + $195 = $def_i21 + 16 | 0; + $196 = $def_i21 + 20 | 0; + $x_sroa_1_4_load313755 = +.75; + $x_sroa_0_0_load303656 = +-7; + $i_057 = 0; + L82 : while (1) { + $y_sroa_1_4_load293550 = $x_sroa_1_4_load313755; + $y_sroa_0_0_load283451 = $x_sroa_0_0_load303656; + $j_052 = $i_057; + while (1) { + HEAP32[$174 >> 2] = 0; + _memset($177 | 0 | 0, 0 | 0 | 0, 32 | 0 | 0); + HEAP8[$176] = 1; + HEAP8[$178] = 1; + HEAP8[$179] = 0; + HEAP8[$180] = 0; + HEAP8[$182] = 1; + HEAPF32[$183 >> 2] = +1; + HEAP32[$181 >> 2] = 2; + $y_sroa_0_0_insert_insert$1 = (HEAPF32[tempDoublePtr >> 2] = $y_sroa_1_4_load293550, HEAP32[tempDoublePtr >> 2] | 0) | 0; + HEAP32[($185 | 0) >> 2] = 0 | (HEAPF32[tempDoublePtr >> 2] = $y_sroa_0_0_load283451, HEAP32[tempDoublePtr >> 2] | 0); + HEAP32[($185 + 4 | 0) >> 2] = $y_sroa_0_0_insert_insert$1; + if (!(((HEAP32[$98 >> 2] | 0) & 2 | 0) == 0)) { + label = 65; + break L82; + } + $205 = __ZN16b2BlockAllocator8AllocateEi($14, 152) | 0; + if (($205 | 0) == 0) { + $209 = 0; + } else { + $208 = $205; + __ZN6b2BodyC2EPK9b2BodyDefP7b2World($208, $bd2, $world); + $209 = $208; + } + HEAP32[($209 + 92 | 0) >> 2] = 0; + HEAP32[($209 + 96 | 0) >> 2] = HEAP32[$118 >> 2] | 0; + $213 = HEAP32[$118 >> 2] | 0; + if (!(($213 | 0) == 0)) { + HEAP32[($213 + 92 | 0) >> 2] = $209; + } + HEAP32[$118 >> 2] = $209; + HEAP32[$126 >> 2] = (HEAP32[$126 >> 2] | 0) + 1 | 0; + HEAP16[$188 >> 1] = 1; + HEAP16[$189 >> 1] = -1; + HEAP16[$190 >> 1] = 0; + HEAP32[$192 >> 2] = 0; + HEAPF32[$193 >> 2] = +.20000000298023224; + HEAPF32[$194 >> 2] = +0; + HEAP8[$196] = 0; + HEAP32[$191 >> 2] = $186; + HEAPF32[$195 >> 2] = +5; + __ZN6b2Body13CreateFixtureEPK12b2FixtureDef($209, $def_i21); + $223 = $j_052 + 1 | 0; + if (($223 | 0) < 40) { + $y_sroa_1_4_load293550 = $y_sroa_1_4_load293550 + +0; + $y_sroa_0_0_load283451 = $y_sroa_0_0_load283451 + 1.125; + $j_052 = $223; + } else { + break; + } + } + $236 = $i_057 + 1 | 0; + if (($236 | 0) < 40) { + $x_sroa_1_4_load313755 = $x_sroa_1_4_load313755 + +1; + $x_sroa_0_0_load303656 = $x_sroa_0_0_load303656 + +.5625; + $i_057 = $236; + } else { + $i3_042 = 0; + break; + } + } + if ((label | 0) == 65) { + ___assert_func(112 | 0 | 0, 109 | 0, 5328 | 0 | 0, 2520 | 0 | 0); + return 0 | 0; + } + while (1) { + __ZN7b2World4StepEfii($world); + $i3_042 = $i3_042 + 1 | 0; + if (($i3_042 | 0) >= ($WARMUP_0 | 0)) { + break; + } + } + $241 = HEAP32[9656 >> 2] | 0; + $242 = _llvm_stacksave() | 0; + $243 = STACKTOP; + STACKTOP = STACKTOP + ($241 * 4 & -1) | 0; + STACKTOP = STACKTOP + 7 >> 3 << 3; + if (($241 | 0) > 0) { + $i4_038 = 0; + while (1) { + $245 = _clock() | 0; + __ZN7b2World4StepEfii($world); + HEAP32[($243 + ($i4_038 << 2) | 0) >> 2] = (_clock() | 0) - $245 | 0; + $i4_038 = $i4_038 + 1 | 0; + if (($i4_038 | 0) >= (HEAP32[9656 >> 2] | 0 | 0)) { + break; + } + } + } + __Z7measurePm($result, $243); + $260 = +HEAPF32[($result + 4 | 0) >> 2]; + _printf(3480 | 0 | 0, (tempInt = STACKTOP, STACKTOP = STACKTOP + 16 | 0, HEAPF64[tempInt >> 3] = +HEAPF32[($result | 0) >> 2], HEAPF64[tempInt + 8 >> 3] = $260, tempInt) | 0) | 0; + _llvm_stackrestore($242 | 0); + __ZN7b2WorldD2Ev($world); + $_0 = 0; + STACKTOP = __stackBase__; + return $_0 | 0; +} +// EMSCRIPTEN_GENERATED_FUNCTIONS: ["a", "b", "rett", "ret2t", "retf", "i32_8", "tempDoublePtr", "boxx", "_main"] From 94b0f737f3dc2b2283f026e0a9a7c1f57adf7bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Thu, 20 Jun 2013 00:19:34 +0300 Subject: [PATCH 33/51] In metadata, store paths parsed from .ll files using forward slashes on Windows. Fixes safe heap line detection on Windows (the code splits on '/' only as path delimiter), closes issue #1233. --- src/modules.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules.js b/src/modules.js index b13ab3c508dd5..d26acbd5671e9 100644 --- a/src/modules.js +++ b/src/modules.js @@ -114,7 +114,8 @@ var Debugging = { m = metadataToParentMetadata[m]; assert(m, 'Confused as to parent metadata for llvm #' + l + ', metadata !' + m); } - this.llvmLineToSourceFile[l] = metadataToFilename[m]; + // Normalize Windows path slashes coming from LLVM metadata, so that forward slashes can be assumed as path delimiters. + this.llvmLineToSourceFile[l] = metadataToFilename[m].replace(/\\5C/g, '/'); } this.on = true; From ea9efe32c9cc66bcbbdb15a1c33bf10dfbe821c5 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 19 Jun 2013 15:08:10 -0700 Subject: [PATCH 34/51] keep |0 on function calls, allow other bitwise ops on heap accesses etc. --- src/parseTools.js | 4 +- src/runtime.js | 6 +- tools/js-optimizer.js | 112 ++++++++++++---------- tools/test-js-optimizer-asm-pre-output.js | 3 + tools/test-js-optimizer-asm-pre.js | 3 + 5 files changed, 71 insertions(+), 57 deletions(-) diff --git a/src/parseTools.js b/src/parseTools.js index 687faaa8820bd..d54480c7da7c7 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1383,7 +1383,7 @@ function makeCopyValues(dest, src, num, type, modifier, align, sep) { if (!isNumber(num)) num = stripCorrections(num); if (!isNumber(align)) align = stripCorrections(align); if (!isNumber(num) || (parseInt(num)/align >= UNROLL_LOOP_MAX)) { - return '_memcpy(' + dest + ', ' + src + ', ' + num + ')'; + return '(_memcpy(' + dest + ', ' + src + ', ' + num + ')|0)'; } num = parseInt(num); if (ASM_JS) { @@ -1465,7 +1465,7 @@ function getFastValue(a, op, b, type) { if ((isNumber(a) && Math.abs(a) < TWO_TWENTY) || (isNumber(b) && Math.abs(b) < TWO_TWENTY) || (bits < 32 && !ASM_JS)) { return '(((' + a + ')*(' + b + '))&' + ((Math.pow(2, bits)-1)|0) + ')'; // keep a non-eliminatable coercion directly on this } - return 'Math.imul(' + a + ',' + b + ')'; + return '(Math.imul(' + a + ',' + b + ')|0)'; } } else { if (a == '0') { diff --git a/src/runtime.js b/src/runtime.js index 9bedfe68aa757..e6d5f962ff1f6 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -25,7 +25,7 @@ var RuntimeGenerator = { sep = sep || ';'; var ret = RuntimeGenerator.alloc(size, 'STACK', false, sep, USE_TYPED_ARRAYS != 2 || (isNumber(size) && parseInt(size) % {{{ STACK_ALIGN }}} == 0)); if (ASSERTIONS) { - ret += sep + 'assert(' + asmCoercion('(STACKTOP|0) < (STACK_MAX|0)', 'i32') + ')'; + ret += sep + '(assert(' + asmCoercion('(STACKTOP|0) < (STACK_MAX|0)', 'i32') + ')|0)'; } return ret; }, @@ -37,11 +37,11 @@ var RuntimeGenerator = { if (USE_TYPED_ARRAYS == 2) { assert(initial % Runtime.STACK_ALIGN == 0); if (ASSERTIONS && Runtime.STACK_ALIGN == 4) { - ret += '; assert(' + asmCoercion('!(STACKTOP&3)', 'i32') + ')'; + ret += '; (assert(' + asmCoercion('!(STACKTOP&3)', 'i32') + ')|0)'; } } if (ASSERTIONS) { - ret += '; assert(' + asmCoercion('(STACKTOP|0) < (STACK_MAX|0)', 'i32') + ')'; + ret += '; (assert(' + asmCoercion('(STACKTOP|0) < (STACK_MAX|0)', 'i32') + ')|0)'; } if (false) { ret += '; _memset(' + asmCoercion('__stackBase__', 'i32') + ', 0, ' + initial + ')'; diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 7f186252f8997..862b39ebf6f6b 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -435,63 +435,69 @@ function simplifyExpressionsPre(ast) { } else { SAFE_BINARY_OPS = set('+', '-', '*'); } - var COERCION_REQUIRING_OPS = set('call', 'sub', 'unary-prefix'); // ops that in asm must be coerced + var COERCION_REQUIRING_OPS = set('sub', 'unary-prefix'); // ops that in asm must be coerced right away var COERCION_REQUIRING_BINARIES = set('*', '/', '%'); // binary ops that in asm must be coerced var ZERO = ['num', 0]; - var rerun = true; - while (rerun) { - rerun = false; - traverse(ast, function process(node, type, stack) { - if (type == 'binary' && node[1] == '|') { - if (node[2][0] == 'num' && node[3][0] == 'num') { - return ['num', node[2][1] | node[3][1]]; - } - var go = false; - if (jsonCompare(node[2], ZERO)) { - // canonicalize order - var temp = node[3]; - node[3] = node[2]; - node[2] = temp; - go = true; - } else if (jsonCompare(node[3], ZERO)) { - go = true; - } - if (!go) { - stack.push(1); - return; - } - // We might be able to remove this correction - for (var i = stack.length-1; i >= 0; i--) { - if (stack[i] == 1) { - if (asm && stack[stack.length-1] != 1) { - if (node[2][0] in COERCION_REQUIRING_OPS || - (node[2][0] == 'binary' && node[2][1] in COERCION_REQUIRING_BINARIES)) break; - } - // we will replace ourselves with the non-zero side. Recursively process that node. - var result = jsonCompare(node[2], ZERO) ? node[3] : node[2], other; - // replace node in-place - node.length = result.length; - for (var j = 0; j < result.length; j++) { - node[j] = result[j]; + + function removeMultipleOrZero() { + var rerun = true; + while (rerun) { + rerun = false; + traverse(ast, function process(node, type, stack) { + if (type == 'binary' && node[1] == '|') { + if (node[2][0] == 'num' && node[3][0] == 'num') { + return ['num', node[2][1] | node[3][1]]; + } + var go = false; + if (jsonCompare(node[2], ZERO)) { + // canonicalize order + var temp = node[3]; + node[3] = node[2]; + node[2] = temp; + go = true; + } else if (jsonCompare(node[3], ZERO)) { + go = true; + } + if (!go) { + stack.push(2); + return; + } + // We might be able to remove this correction + for (var i = stack.length-1; i >= 0; i--) { + if (stack[i] >= 1) { + if (asm) { + if (stack[stack.length-1] < 2 && node[2][0] == 'call') break; // we can only remove multiple |0s on these + if (stack[stack.length-1] < 1 && (node[2][0] in COERCION_REQUIRING_OPS || + (node[2][0] == 'binary' && node[2][1] in COERCION_REQUIRING_BINARIES))) break; // we can remove |0 or >>2 + } + // we will replace ourselves with the non-zero side. Recursively process that node. + var result = jsonCompare(node[2], ZERO) ? node[3] : node[2], other; + // replace node in-place + node.length = result.length; + for (var j = 0; j < result.length; j++) { + node[j] = result[j]; + } + rerun = true; + return process(result, result[0], stack); + } else if (stack[i] == -1) { + break; // Too bad, we can't } - rerun = true; - return process(result, result[0], stack); - } else if (stack[i] == -1) { - break; // Too bad, we can't } + stack.push(2); // From here on up, no need for this kind of correction, it's done at the top + // (Add this at the end, so it is only added if we did not remove it) + } else if (type == 'binary' && node[1] in USEFUL_BINARY_OPS) { + stack.push(1); + } else if ((type == 'binary' && node[1] in SAFE_BINARY_OPS) || type == 'num' || type == 'name') { + stack.push(0); // This node is safe in that it does not interfere with this optimization + } else { + stack.push(-1); // This node is dangerous! Give up if you see this before you see '1' } - stack.push(1); // From here on up, no need for this kind of correction, it's done at the top - // (Add this at the end, so it is only added if we did not remove it) - } else if (type == 'binary' && node[1] in USEFUL_BINARY_OPS) { - stack.push(1); - } else if ((type == 'binary' && node[1] in SAFE_BINARY_OPS) || type == 'num' || type == 'name') { - stack.push(0); // This node is safe in that it does not interfere with this optimization - } else { - stack.push(-1); // This node is dangerous! Give up if you see this before you see '1' - } - }, null, []); + }, null, []); + } } + removeMultipleOrZero(); + // & and heap-related optimizations var heapBits, heapUnsigned; @@ -502,7 +508,7 @@ function simplifyExpressionsPre(ast) { return true; } - var hasTempDoublePtr = false; + var hasTempDoublePtr = false, rerunOrZeroPass = false; traverse(ast, function(node, type) { if (type == 'name') { @@ -537,7 +543,6 @@ function simplifyExpressionsPre(ast) { node[2][0] == 'binary' && node[2][1] == '<<' && node[2][3][0] == 'num' && node[2][2][0] == 'sub' && node[2][2][1][0] == 'name') { // collapse HEAPU?8[..] << 24 >> 24 etc. into HEAP8[..] | 0 - // TODO: run this before | 0 | 0 removal, because we generate | 0 var amount = node[3][1]; var name = node[2][2][1][1]; if (amount == node[2][3][1] && parseHeap(name)) { @@ -546,6 +551,7 @@ function simplifyExpressionsPre(ast) { node[1] = '|'; node[2] = node[2][2]; node[3][1] = 0; + rerunOrZeroPass = true; return node; } } @@ -578,6 +584,8 @@ function simplifyExpressionsPre(ast) { } }); + if (rerunOrZeroPass) removeMultipleOrZero(); + if (asm) { if (hasTempDoublePtr) { traverse(ast, function(node, type) { diff --git a/tools/test-js-optimizer-asm-pre-output.js b/tools/test-js-optimizer-asm-pre-output.js index 903de1f9b8922..1716059f324b0 100644 --- a/tools/test-js-optimizer-asm-pre-output.js +++ b/tools/test-js-optimizer-asm-pre-output.js @@ -15,6 +15,9 @@ function a() { +f(); f(+(+h() + 5)); $140 = $p_3_i + (-$mantSize_0_i | 0) | 0; + f(g() | 0); + f(g() | 0 & -1); + f((g() | 0) >> 2); } function b($this, $__n) { $this = $this | 0; diff --git a/tools/test-js-optimizer-asm-pre.js b/tools/test-js-optimizer-asm-pre.js index aac70b6004e7e..14531c231c48d 100644 --- a/tools/test-js-optimizer-asm-pre.js +++ b/tools/test-js-optimizer-asm-pre.js @@ -16,6 +16,9 @@ function a() { +f(); f(+(+h() + 5)); $140 = $p_3_i + (-$mantSize_0_i | 0) | 0; + f(g() | 0 | 0); + f(g() | 0 & -1); + f((g() | 0) >> 2); } function b($this, $__n) { $this = $this | 0; From e871c2ee89303d8f336711e20d551073fab30919 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 19 Jun 2013 16:07:33 -0700 Subject: [PATCH 35/51] properly coerce imprecise i64 math calls --- src/parseTools.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parseTools.js b/src/parseTools.js index d54480c7da7c7..37a6c418be4cf 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -710,9 +710,9 @@ function splitI64(value, floatConversion) { var lowInput = legalizedI64s ? value : 'VALUE'; if (floatConversion && ASM_JS) lowInput = asmFloatToInt(lowInput); if (legalizedI64s) { - return [lowInput + '>>>0', 'Math.min(Math.floor((' + value + ')/' + asmEnsureFloat(4294967296, 'float') + '), ' + asmEnsureFloat(4294967295, 'float') + ')>>>0']; + return [lowInput + '>>>0', asmCoercion('Math.min(' + asmCoercion('Math.floor((' + value + ')/' + asmEnsureFloat(4294967296, 'float') + ')', 'double') + ', ' + asmEnsureFloat(4294967295, 'float') + ')', 'i32') + '>>>0']; } else { - return makeInlineCalculation(makeI64(lowInput + '>>>0', 'Math.min(Math.floor(VALUE/' + asmEnsureFloat(4294967296, 'float') + '), ' + asmEnsureFloat(4294967295, 'float') + ')>>>0'), value, 'tempBigIntP'); + return makeInlineCalculation(makeI64(lowInput + '>>>0', asmCoercion('Math.min(' + asmCoercion('Math.floor(VALUE/' + asmEnsureFloat(4294967296, 'float') + ')', 'double') + ', ' + asmEnsureFloat(4294967295, 'float') + ')', 'i32') + '>>>0'), value, 'tempBigIntP'); } } function mergeI64(value, unsigned) { From 06665ab130347fa69709f92f1174518998cfb29b Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 19 Jun 2013 16:07:48 -0700 Subject: [PATCH 36/51] fix memmove --- src/library.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library.js b/src/library.js index 33dcbd5f219b3..01a6780417bfa 100644 --- a/src/library.js +++ b/src/library.js @@ -4399,7 +4399,7 @@ LibraryManager.library = { {{{ makeSetValueAsm('dest', 0, makeGetValueAsm('src', 0, 'i8'), 'i8') }}}; } } else { - _memcpy(dest, src, num); + _memcpy(dest, src, num) | 0; } }, llvm_memmove_i32: 'memmove', From 8215a28597a464489d4678aa57cdccef80f427df Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 19 Jun 2013 16:42:35 -0700 Subject: [PATCH 37/51] fix bug with reducing f()|0|const --- tools/js-optimizer.js | 2 +- tools/test-js-optimizer-asm-pre-output.js | 1 + tools/test-js-optimizer-asm-pre.js | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 862b39ebf6f6b..b02ae3cca7584 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -459,7 +459,7 @@ function simplifyExpressionsPre(ast) { go = true; } if (!go) { - stack.push(2); + stack.push(1); return; } // We might be able to remove this correction diff --git a/tools/test-js-optimizer-asm-pre-output.js b/tools/test-js-optimizer-asm-pre-output.js index 1716059f324b0..0e95580fc67e2 100644 --- a/tools/test-js-optimizer-asm-pre-output.js +++ b/tools/test-js-optimizer-asm-pre-output.js @@ -18,6 +18,7 @@ function a() { f(g() | 0); f(g() | 0 & -1); f((g() | 0) >> 2); + $56 = _fcntl() | 0 | 1; } function b($this, $__n) { $this = $this | 0; diff --git a/tools/test-js-optimizer-asm-pre.js b/tools/test-js-optimizer-asm-pre.js index 14531c231c48d..4f3ba7804dbbc 100644 --- a/tools/test-js-optimizer-asm-pre.js +++ b/tools/test-js-optimizer-asm-pre.js @@ -19,6 +19,7 @@ function a() { f(g() | 0 | 0); f(g() | 0 & -1); f((g() | 0) >> 2); + $56 = (_fcntl() | 0) | 1; } function b($this, $__n) { $this = $this | 0; From 635420dac1eae4970a506ab8805500d73f6266a2 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 19 Jun 2013 16:59:18 -0700 Subject: [PATCH 38/51] update fastLong.js --- src/fastLong.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/fastLong.js b/src/fastLong.js index d1ce5d39e8e72..4f6efd9fdd6fe 100644 --- a/src/fastLong.js +++ b/src/fastLong.js @@ -5,12 +5,12 @@ function ___muldsi3($a, $b) { var $1 = 0, $2 = 0, $3 = 0, $6 = 0, $8 = 0, $11 = 0, $12 = 0; $1 = $a & 65535; $2 = $b & 65535; - $3 = Math.imul($2, $1); + $3 = Math.imul($2, $1) | 0; $6 = $a >>> 16; - $8 = ($3 >>> 16) + Math.imul($2, $6) | 0; + $8 = ($3 >>> 16) + (Math.imul($2, $6) | 0) | 0; $11 = $b >>> 16; - $12 = Math.imul($11, $1); - return (tempRet0 = (($8 >>> 16) + Math.imul($11, $6) | 0) + ((($8 & 65535) + $12 | 0) >>> 16) | 0, 0 | ($8 + $12 << 16 | $3 & 65535)) | 0; + $12 = Math.imul($11, $1) | 0; + return (tempRet0 = (($8 >>> 16) + (Math.imul($11, $6) | 0) | 0) + ((($8 & 65535) + $12 | 0) >>> 16) | 0, 0 | ($8 + $12 << 16 | $3 & 65535)) | 0; } function ___divdi3($a$0, $a$1, $b$0, $b$1) { $a$0 = $a$0 | 0; @@ -47,7 +47,7 @@ function ___remdi3($a$0, $a$1, $b$0, $b$1) { $4$0 = _i64Subtract($1$0 ^ $a$0, $1$1 ^ $a$1, $1$0, $1$1) | 0; $4$1 = tempRet0; $6$0 = _i64Subtract($2$0 ^ $b$0, $2$1 ^ $b$1, $2$0, $2$1) | 0; - ___udivmoddi4($4$0, $4$1, $6$0, tempRet0, $rem); + ___udivmoddi4($4$0, $4$1, $6$0, tempRet0, $rem) | 0; $10$0 = _i64Subtract(HEAP32[$rem >> 2] ^ $1$0, HEAP32[$rem + 4 >> 2] ^ $1$1, $1$0, $1$1) | 0; $10$1 = tempRet0; STACKTOP = __stackBase__; @@ -63,8 +63,8 @@ function ___muldi3($a$0, $a$1, $b$0, $b$1) { $y_sroa_0_0_extract_trunc = $b$0; $1$0 = ___muldsi3($x_sroa_0_0_extract_trunc, $y_sroa_0_0_extract_trunc) | 0; $1$1 = tempRet0; - $2 = Math.imul($a$1, $y_sroa_0_0_extract_trunc); - return (tempRet0 = (Math.imul($b$1, $x_sroa_0_0_extract_trunc) + $2 | 0) + $1$1 | $1$1 & 0, 0 | $1$0 & -1) | 0; + $2 = Math.imul($a$1, $y_sroa_0_0_extract_trunc) | 0; + return (tempRet0 = ((Math.imul($b$1, $x_sroa_0_0_extract_trunc) | 0) + $2 | 0) + $1$1 | $1$1 & 0, 0 | $1$0 & -1) | 0; } function ___udivdi3($a$0, $a$1, $b$0, $b$1) { $a$0 = $a$0 | 0; @@ -84,7 +84,7 @@ function ___uremdi3($a$0, $a$1, $b$0, $b$1) { __stackBase__ = STACKTOP; STACKTOP = STACKTOP + 8 | 0; $rem = __stackBase__ | 0; - ___udivmoddi4($a$0, $a$1, $b$0, $b$1, $rem); + ___udivmoddi4($a$0, $a$1, $b$0, $b$1, $rem) | 0; STACKTOP = __stackBase__; return (tempRet0 = HEAP32[$rem + 4 >> 2] | 0, HEAP32[$rem >> 2] | 0) | 0; } @@ -258,7 +258,7 @@ function ___udivmoddi4($a$0, $a$1, $b$0, $b$1, $rem) { $149 = $carry_0203 | $q_sroa_0_1199 << 1; $r_sroa_0_0_insert_insert42$0 = 0 | ($r_sroa_0_1201 << 1 | $q_sroa_1_1198 >>> 31); $r_sroa_0_0_insert_insert42$1 = $r_sroa_0_1201 >>> 31 | $r_sroa_1_1200 << 1 | 0; - _i64Subtract($137$0, $137$1, $r_sroa_0_0_insert_insert42$0, $r_sroa_0_0_insert_insert42$1); + _i64Subtract($137$0, $137$1, $r_sroa_0_0_insert_insert42$0, $r_sroa_0_0_insert_insert42$1) | 0; $150$1 = tempRet0; $151$0 = $150$1 >> 31 | (($150$1 | 0) < 0 ? -1 : 0) << 1; $152 = $151$0 & 1; From 759cfa2ee92cef2834d6cbf95bf69eef0bbe02b1 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 19 Jun 2013 18:39:03 -0700 Subject: [PATCH 39/51] move lua binarytree args handling into lua script --- tests/lua/binarytrees.lua | 17 ++++++++++++++++- tests/runner.py | 16 +--------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/tests/lua/binarytrees.lua b/tests/lua/binarytrees.lua index 2ae3dd69a43aa..58c0ce87c1cb3 100644 --- a/tests/lua/binarytrees.lua +++ b/tests/lua/binarytrees.lua @@ -21,7 +21,22 @@ local function ItemCheck(tree) end end -local N = tonumber(arg and arg[1]) or 0 +local N = tonumber(arg and arg[1]) or 4 + +if N == 0 then + N = 0 +elseif N == 1 then + N = 9.5 +elseif N == 2 then + N = 11.99 +elseif N == 3 then + N = 12.85 +elseif N == 4 then + N = 14.72 +elseif N == 5 then + N = 15.82 +end + local mindepth = 4 local maxdepth = mindepth + 2 if maxdepth < N then maxdepth = N end diff --git a/tests/runner.py b/tests/runner.py index 610a39f690ff7..8f084abfe342d 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -13661,21 +13661,7 @@ def output_parser(output): def test_zzz_lua_binarytrees(self): # js version: ['binarytrees.lua', {0: 0, 1: 9.5, 2: 11.99, 3: 12.85, 4: 14.72, 5: 15.82}[arguments[0]]] - def args_processor(args): - arg = int(DEFAULT_ARG) - if arg == 0: - return args + ['0'] - elif arg == 1: - return args + ['9.5'] - elif arg == 2: - return args + ['11.99'] - elif arg == 3: - return args + ['12.85'] - elif arg == 4: - return args + ['14.72'] - elif arg == 5: - return args + ['15.82'] - self.lua('binarytrees', 'long lived tree of depth', args_processor=args_processor) + self.lua('binarytrees', 'long lived tree of depth') def test_zzz_zlib(self): src = open(path_from_root('tests', 'zlib', 'benchmark.c'), 'r').read() From 038da363d94113ae85c8843ff951fef9476e20a4 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 19 Jun 2013 19:09:19 -0700 Subject: [PATCH 40/51] hardcode arguments in benchmarks, even lua --- tests/runner.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/runner.py b/tests/runner.py index 8f084abfe342d..210e5e5979183 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -133,7 +133,7 @@ def hardcode_arguments(self, filename, args): # Hardcode in the arguments, so js is portable without manual commandlinearguments if not args: return js = open(filename).read() - open(filename, 'w').write(js.replace('run();', 'run(%s);' % str(args))) + open(filename, 'w').write(js.replace('run();', 'run(%s + Module["arguments"]);' % str(args))) def prep_ll_run(self, filename, ll_file, force_recompile=False, build_ll_hook=None): if ll_file.endswith(('.bc', '.o')): @@ -13314,17 +13314,26 @@ def do_benchmark(self, name, src, expected_output='FAIL', args=[], emcc_args=[], f.close() final_filename = os.path.join(dirname, name + '.js') + open('hardcode.py', 'w').write(''' +def process(filename): + js = open(filename).read() + replaced = js.replace("run();", "run(%s.concat(Module[\\"arguments\\"]));") + assert js != replaced + open(filename, 'w').write(replaced) +import sys +process(sys.argv[1]) +''' % str(args[:-1]) # do not hardcode in the last argument, the default arg +) + try_delete(final_filename) output = Popen([PYTHON, EMCC, filename, #'-O3', '-O2', '-s', 'DOUBLE_MODE=0', '-s', 'PRECISE_I64_MATH=0', - '--llvm-lto', '1', '--memory-init-file', '0', + '--llvm-lto', '1', '--memory-init-file', '0', '--js-transform', 'python hardcode.py', '-s', 'TOTAL_MEMORY=128*1024*1024', '--closure', '1', '-o', final_filename] + shared_args + emcc_args, stdout=PIPE, stderr=self.stderr_redirect).communicate() assert os.path.exists(final_filename), 'Failed to compile file: ' + output[0] - self.hardcode_arguments(final_filename, args) - # Run JS global total_times, tests_done times = [] @@ -13650,7 +13659,7 @@ def lua(self, benchmark, expected, output_parser=None, args_processor=None): native_args = self.get_library('lua_native', [os.path.join('src', 'lua'), os.path.join('src', 'liblua.a')], make=['make', 'generic'], configure=None, native=True) self.do_benchmark('lua_' + benchmark, '', expected, - force_c=True, args=[benchmark + '.lua'], emcc_args=emcc_args, native_args=native_args, native_exec=os.path.join('building', 'lua_native', 'src', 'lua'), + force_c=True, args=[benchmark + '.lua', DEFAULT_ARG], emcc_args=emcc_args, native_args=native_args, native_exec=os.path.join('building', 'lua_native', 'src', 'lua'), output_parser=output_parser, args_processor=args_processor) def test_zzz_lua_scimark(self): From f7e14034b7b3561c1570b81b3209f93a0b85b716 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 19 Jun 2013 19:14:37 -0700 Subject: [PATCH 41/51] fix CHECK_ALIGN --- src/parseTools.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parseTools.js b/src/parseTools.js index 37a6c418be4cf..0b83a12b8e5b9 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1049,7 +1049,7 @@ function getHeapOffset(offset, type, forceAsm) { offset = '(' + offset + ')'; if (shifts != 0) { if (CHECK_HEAP_ALIGN) { - return '(CHECK_ALIGN_' + sz + '(' + offset + '|0)>>' + shifts + ')'; + return '((CHECK_ALIGN_' + sz + '(' + offset + '|0)|0)>>' + shifts + ')'; } else { return '(' + offset + '>>' + shifts + ')'; } From f2121fe18499cd09b870a1bd8ef5f3259a806d28 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 20 Jun 2013 09:45:32 -0700 Subject: [PATCH 42/51] ensure a coercion on invoke calls --- src/jsifier.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/jsifier.js b/src/jsifier.js index 88b9d9f6fc7f9..e9bc9a7971d3e 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -1185,8 +1185,13 @@ function JSify(data, functionsOnly, givenFunctions) { if (disabled) { ret = call_ + ';'; } else if (ASM_JS) { + if (item.type != 'void') call_ = asmCoercion(call_, item.type); // ensure coercion to ffi in comma operator call_ = call_.replace('; return', ''); // we auto-add returns when aborting, but do not need them here - ret = '(__THREW__ = 0,' + call_ + ');'; + if (item.type == 'void') { + ret = '__THREW__ = 0;' + call_ + ';'; + } else { + ret = '(__THREW__ = 0,' + call_ + ');'; + } } else { ret = '(function() { try { __THREW__ = 0; return ' + call_ + ' ' From 76ac002779493f5402b7db3c0c44461a14c8c543 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 20 Jun 2013 10:45:25 -0700 Subject: [PATCH 43/51] fix browser test harness --- tests/runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/runner.py b/tests/runner.py index 210e5e5979183..bcd8e84cf9aab 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -12698,7 +12698,7 @@ def btest(self, filename, expected=None, reference=None, reference_slack=0, src = filename filename = 'main.cpp' else: - with open(filepath) as f: f.read() + with open(filepath) as f: src = f.read() with open(temp_filepath, 'w') as f: f.write(self.with_report_result(src)) else: expected = [str(i) for i in range(0, reference_slack+1)] From 1084d02ba5886d786f57655307c47e5d554cb956 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 20 Jun 2013 11:31:36 -0700 Subject: [PATCH 44/51] asmify copyTempFloat|Double --- emscripten.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/emscripten.py b/emscripten.py index c9a5eb59747d2..56f592738842c 100755 --- a/emscripten.py +++ b/emscripten.py @@ -407,7 +407,7 @@ def fix_item(item): math_envs = ['Math.min'] # TODO: move min to maths asm_setup += '\n'.join(['var %s = %s;' % (f.replace('.', '_'), f) for f in math_envs]) - basic_funcs = ['abort', 'assert', 'asmPrintInt', 'asmPrintFloat', 'copyTempDouble', 'copyTempFloat'] + [m.replace('.', '_') for m in math_envs] + basic_funcs = ['abort', 'assert', 'asmPrintInt', 'asmPrintFloat'] + [m.replace('.', '_') for m in math_envs] if settings['RESERVED_FUNCTION_POINTERS'] > 0: basic_funcs.append('jsCall') if settings['SAFE_HEAP']: basic_funcs += ['SAFE_HEAP_LOAD', 'SAFE_HEAP_STORE', 'SAFE_HEAP_CLEAR'] if settings['CHECK_HEAP_ALIGN']: basic_funcs += ['CHECK_ALIGN_2', 'CHECK_ALIGN_4', 'CHECK_ALIGN_8'] @@ -555,6 +555,24 @@ def math_fix(g): threwValue = value; } } + function copyTempFloat(ptr) { + ptr = ptr|0; + HEAP8[tempDoublePtr] = HEAP8[ptr]; + HEAP8[tempDoublePtr+1|0] = HEAP8[ptr+1|0]; + HEAP8[tempDoublePtr+2|0] = HEAP8[ptr+2|0]; + HEAP8[tempDoublePtr+3|0] = HEAP8[ptr+3|0]; + } + function copyTempDouble(ptr) { + ptr = ptr|0; + HEAP8[tempDoublePtr] = HEAP8[ptr]; + HEAP8[tempDoublePtr+1|0] = HEAP8[ptr+1|0]; + HEAP8[tempDoublePtr+2|0] = HEAP8[ptr+2|0]; + HEAP8[tempDoublePtr+3|0] = HEAP8[ptr+3|0]; + HEAP8[tempDoublePtr+4|0] = HEAP8[ptr+4|0]; + HEAP8[tempDoublePtr+5|0] = HEAP8[ptr+5|0]; + HEAP8[tempDoublePtr+6|0] = HEAP8[ptr+6|0]; + HEAP8[tempDoublePtr+7|0] = HEAP8[ptr+7|0]; + } ''' + ''.join([''' function setTempRet%d(value) { value = value|0; From 97d19be7f46bb3b0862e575fc6e06abafca74df7 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 20 Jun 2013 14:48:00 -0700 Subject: [PATCH 45/51] remove unneeded argument handling in lua-scimark --- tests/lua/scimark.lua | 50 +++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/lua/scimark.lua b/tests/lua/scimark.lua index 7e37c219d1d03..34fbc4fff29d8 100644 --- a/tests/lua/scimark.lua +++ b/tests/lua/scimark.lua @@ -387,31 +387,31 @@ end --printf("Lua SciMark %s based on SciMark 2.0a. %s.\n\n", -- SCIMARK_VERSION, SCIMARK_COPYRIGHT) -while arg and arg[1] do - local a = table.remove(arg, 1) - if a == "-noffi" then - package.preload.ffi = nil - elseif a == "-small" then - SIZE_SELECT = "small" - elseif a == "-large" then - SIZE_SELECT = "large" - elseif benchmarks[a] then - local p = benchmarks[SIZE_SELECT][a] - measure(MIN_TIME, a, tonumber(arg[1]) or p[1], tonumber(arg[2]) or p[2]) - return - else - printf("Usage: scimark [-noffi] [-small|-large] [BENCH params...]\n\n") - printf("BENCH -small -large\n") - printf("---------------------------------------\n") - for _,name in ipairs(benchmarks) do - printf("%-7s %-13s %s\n", name, - fmtparams(unpack(benchmarks.small[name])), - fmtparams(unpack(benchmarks.large[name]))) - end - printf("\n") - os.exit(1) - end -end +--while arg and arg[1] do +-- local a = table.remove(arg, 1) +-- if a == "-noffi" then +-- package.preload.ffi = nil +-- elseif a == "-small" then +-- SIZE_SELECT = "small" +-- elseif a == "-large" then +-- SIZE_SELECT = "large" +-- elseif benchmarks[a] then +-- local p = benchmarks[SIZE_SELECT][a] +-- measure(MIN_TIME, a, tonumber(arg[1]) or p[1], tonumber(arg[2]) or p[2]) +-- return +-- else +-- printf("Usage: scimark [-noffi] [-small|-large] [BENCH params...]\n\n") +-- printf("BENCH -small -large\n") +-- printf("---------------------------------------\n") +-- for _,name in ipairs(benchmarks) do +-- printf("%-7s %-13s %s\n", name, +-- fmtparams(unpack(benchmarks.small[name])), +-- fmtparams(unpack(benchmarks.large[name]))) +-- end +-- printf("\n") +-- os.exit(1) +-- end +--end local params = benchmarks[SIZE_SELECT] local sum = 0 From f96eb4095c33358adf4d68bf5acfb6bc30059a1b Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 20 Jun 2013 17:27:30 -0700 Subject: [PATCH 46/51] do not return node in main simplifyNotCompsPass all the time, it thinks it is being replaced and adds much overhead --- tools/js-optimizer.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index b02ae3cca7584..432c6208f09c5 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -1116,11 +1116,15 @@ function simplifyNotCompsDirect(node) { return node[2][2]; } } - return node; + if (!simplifyNotCompsPass) return node; } +var simplifyNotCompsPass = false; + function simplifyNotComps(ast) { + simplifyNotCompsPass = true; traverse(ast, simplifyNotCompsDirect); + simplifyNotCompsPass = false; } function simplifyExpressionsPost(ast) { From 4654f7b59b99d5b3dcddc0fce9938d7e9f4601e0 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 21 Jun 2013 11:22:51 -0700 Subject: [PATCH 47/51] todo --- emcc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/emcc b/emcc index b8230e95dea9d..e76c987051a85 100755 --- a/emcc +++ b/emcc @@ -1132,6 +1132,8 @@ try: libcxx_symbols = read_symbols(shared.path_from_root('system', 'lib', 'libcxx', 'symbols'), exclude=libc_symbols) libcxxabi_symbols = read_symbols(shared.path_from_root('system', 'lib', 'libcxxabi', 'symbols'), exclude=libc_symbols) + # XXX we should disable EMCC_DEBUG (and EMCC_OPTIMIZE_NORMALLY?) when building libs, just like in the relooper + def build_libc(lib_filename, files): o_s = [] prev_cxx = os.environ.get('EMMAKEN_CXX') From 36924330b0d0a67bd5894bb91140e8131e396cd7 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 21 Jun 2013 12:02:52 -0700 Subject: [PATCH 48/51] do not eliminate loop vars when there is a shared helper --- tools/eliminator/asm-eliminator-test-output.js | 13 +++++++++++++ tools/eliminator/asm-eliminator-test.js | 15 ++++++++++++++- tools/js-optimizer.js | 9 +++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/tools/eliminator/asm-eliminator-test-output.js b/tools/eliminator/asm-eliminator-test-output.js index 2ce77b789124d..358a83df8f92b 100644 --- a/tools/eliminator/asm-eliminator-test-output.js +++ b/tools/eliminator/asm-eliminator-test-output.js @@ -5049,6 +5049,19 @@ function looop7() { HEAP32[$old_0_i107_i >> 2] = HEAP32[$696 >> 2] | 0; while (1) {} } +function looop8() { + var i = 0, j = 0, a = 0; + while (1) { + do_it(i, j); + a = i + j | 0; + if (condition(helper)) { + break; + } else { + i = a; + j = a; + } + } +} function multiloop($n_0, $35) { $n_0 = $n_0 | 0; $35 = $35 | 0; diff --git a/tools/eliminator/asm-eliminator-test.js b/tools/eliminator/asm-eliminator-test.js index f45f082bf4fca..d082f70a56817 100644 --- a/tools/eliminator/asm-eliminator-test.js +++ b/tools/eliminator/asm-eliminator-test.js @@ -6775,6 +6775,19 @@ function looop7() { while (1) { } } +function looop8() { + var i = 0, j = 0, a = 0; + while (1) { + do_it(i, j); + a = (i + j)|0; + if (condition(helper)) { + break; + } else { + i = a; // helper used twice! + j = a; + } + } +} function multiloop($n_0, $35) { $n_0 = $n_0 | 0; $35 = $35 | 0; @@ -6838,5 +6851,5 @@ function tempDouble2($46, $14, $28, $42, $20, $32, $45) { HEAP32[$45 + 4 >> 2] = $_sroa_06_0_insert_insert$1; HEAP32[$45 + 8 >> 2] = $_sroa_06_0_insert_insert$1; } -// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "multiloop", "multiloop2", "tempDouble2"] +// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "looop8", "multiloop", "multiloop2", "tempDouble2"] diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 432c6208f09c5..aa5a3afc7755f 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -2438,7 +2438,10 @@ function eliminate(ast, memSafe) { } traverseInOrder(node); } + //var eliminationLimit = 0; // used to debugging purposes function doEliminate(name, node) { + //if (eliminationLimit == 0) return; + //eliminationLimit--; //printErr('elim!!!!! ' + name); // yes, eliminate! varsToRemove[name] = 2; // both assign and var definitions can have other vars we must clean up @@ -2587,7 +2590,13 @@ function eliminate(ast, memSafe) { } if (looperUsed) return; } + for (var l = 0; l < helpers.length; l++) { + for (var k = 0; k < helpers.length; k++) { + if (l != k && helpers[l] == helpers[k]) return; // it is complicated to handle a shared helper, abort + } + } // hurrah! this is safe to do + //printErr("ELIM LOOP VAR " + JSON.stringify(loopers) + ' :: ' + JSON.stringify(helpers)); for (var l = 0; l < loopers.length; l++) { var looper = loopers[l]; var helper = helpers[l]; From c249e1fdaa811775643d9d573f99440c8fdfb1c2 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 21 Jun 2013 14:36:44 -0700 Subject: [PATCH 49/51] decrease indentation level in js optimizer --- tools/js-optimizer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index aa5a3afc7755f..8e9e229e73ffa 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -153,7 +153,7 @@ function astToSrc(ast, compress) { return uglify.uglify.gen_code(ast, { ascii_only: true, beautify: !compress, - indent_level: 2 + indent_level: 1 }); } From ab52273a5dd207187a2959a3f1e08c4196665bcc Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 21 Jun 2013 14:43:46 -0700 Subject: [PATCH 50/51] decrease indentation in jsifier --- src/jsifier.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/jsifier.js b/src/jsifier.js index e9bc9a7971d3e..062bae6cc3aa1 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -14,6 +14,8 @@ var asmLibraryFunctions = []; var SETJMP_LABEL = -1; +var INDENTATION = ' '; + // JSifier function JSify(data, functionsOnly, givenFunctions) { var mainPass = !functionsOnly; @@ -591,13 +593,13 @@ function JSify(data, functionsOnly, givenFunctions) { func.JS += 'function ' + func.ident + '(' + paramIdents.join(', ') + ') {\n'; if (PGO) { - func.JS += ' PGOMonitor.called["' + func.ident + '"] = 1;\n'; + func.JS += INDENTATION + 'PGOMonitor.called["' + func.ident + '"] = 1;\n'; } if (ASM_JS) { // spell out argument types func.params.forEach(function(param) { - func.JS += ' ' + param.ident + ' = ' + asmCoercion(param.ident, param.type) + ';\n'; + func.JS += INDENTATION + param.ident + ' = ' + asmCoercion(param.ident, param.type) + ';\n'; }); // spell out local variables @@ -611,7 +613,7 @@ function JSify(data, functionsOnly, givenFunctions) { i += chunkSize; } for (i = 0; i < chunks.length; i++) { - func.JS += ' var ' + chunks[i].map(function(v) { + func.JS += INDENTATION + 'var ' + chunks[i].map(function(v) { var type = getImplementationType(v); if (!isIllegalType(type) || v.ident.indexOf('$', 1) > 0) { // not illegal, or a broken up illegal return v.ident + ' = ' + asmInitializer(type); //, func.variables[v.ident].impl); @@ -627,7 +629,7 @@ function JSify(data, functionsOnly, givenFunctions) { if (true) { // TODO: optimize away when not needed if (CLOSURE_ANNOTATIONS) func.JS += '/** @type {number} */'; - func.JS += ' var label = 0;\n'; + func.JS += INDENTATION + 'var label = 0;\n'; } if (ASM_JS) { @@ -636,12 +638,12 @@ function JSify(data, functionsOnly, givenFunctions) { hasByVal = hasByVal || param.byVal; }); if (hasByVal) { - func.JS += ' var tempParam = 0;\n'; + func.JS += INDENTATION + 'var tempParam = 0;\n'; } } // Prepare the stack, if we need one. If we have other stack allocations, force the stack to be set up. - func.JS += ' ' + RuntimeGenerator.stackEnter(func.initialStack, func.otherStackAllocations) + ';\n'; + func.JS += INDENTATION + RuntimeGenerator.stackEnter(func.initialStack, func.otherStackAllocations) + ';\n'; // Make copies of by-value params // XXX It is not clear we actually need this. While without this we fail, it does look like @@ -654,7 +656,7 @@ function JSify(data, functionsOnly, givenFunctions) { if (param.byVal) { var type = removePointing(param.type); var typeInfo = Types.types[type]; - func.JS += ' ' + (ASM_JS ? '' : 'var ') + 'tempParam = ' + param.ident + '; ' + param.ident + ' = ' + RuntimeGenerator.stackAlloc(typeInfo.flatSize) + ';' + + func.JS += INDENTATION + (ASM_JS ? '' : 'var ') + 'tempParam = ' + param.ident + '; ' + param.ident + ' = ' + RuntimeGenerator.stackAlloc(typeInfo.flatSize) + ';' + makeCopyValues(param.ident, 'tempParam', typeInfo.flatSize, 'null', null, param.byVal) + ';\n'; } }); @@ -728,12 +730,12 @@ function JSify(data, functionsOnly, givenFunctions) { } ret += 'switch(' + asmCoercion('label', 'i32') + ') {\n'; ret += block.labels.map(function(label) { - return indent + ' case ' + getLabelId(label.ident) + ': ' + (SHOW_LABELS ? '// ' + getOriginalLabelId(label.ident) : '') + '\n' - + getLabelLines(label, indent + ' '); + return indent + INDENTATION + 'case ' + getLabelId(label.ident) + ': ' + (SHOW_LABELS ? '// ' + getOriginalLabelId(label.ident) : '') + '\n' + + getLabelLines(label, indent + INDENTATION + INDENTATION); }).join('\n') + '\n'; if (func.setjmpTable && ASM_JS) { // emit a label in which we write to the proper local variable, before jumping to the actual label - ret += ' case ' + SETJMP_LABEL + ': '; + ret += INDENTATION + 'case ' + SETJMP_LABEL + ': '; ret += func.setjmpTable.map(function(triple) { // original label, label we created for right after the setjmp, variable setjmp result goes into return 'if ((setjmpLabel|0) == ' + getLabelId(triple.oldLabel) + ') { ' + triple.assignTo + ' = threwValue; label = ' + triple.newLabel + ' }\n'; }).join(' else '); @@ -741,7 +743,7 @@ function JSify(data, functionsOnly, givenFunctions) { ret += '__THREW__ = threwValue = 0;\n'; ret += 'break;\n'; } - if (ASSERTIONS) ret += indent + ' default: assert(0' + (ASM_JS ? '' : ', "bad label: " + label') + ');\n'; + if (ASSERTIONS) ret += indent + INDENTATION + 'default: assert(0' + (ASM_JS ? '' : ', "bad label: " + label') + ');\n'; ret += indent + '}\n'; if (func.setjmpTable && !ASM_JS) { ret += ' } catch(e) { if (!e.longjmp || !(e.id in mySetjmpIds)) throw(e); setjmpTable[setjmpLabels[e.id]](e.value) }'; @@ -797,13 +799,13 @@ function JSify(data, functionsOnly, givenFunctions) { } return ret; } - func.JS += walkBlock(func.block, ' '); + func.JS += walkBlock(func.block, INDENTATION); // Finalize function if (LABEL_DEBUG && functionNameFilterTest(func.ident)) func.JS += " INDENT = INDENT.substr(0, INDENT.length-2);\n"; // Ensure a return in a function with a type that returns, even if it lacks a return (e.g., if it aborts()) if (RELOOP && func.lines.length > 0 && func.returnType != 'void') { var returns = func.labels.filter(function(label) { return label.lines[label.lines.length-1].intertype == 'return' }).length; - if (returns == 0) func.JS += ' return ' + asmCoercion('0', func.returnType); + if (returns == 0) func.JS += INDENTATION + 'return ' + asmCoercion('0', func.returnType); } func.JS += '}\n'; @@ -1121,7 +1123,7 @@ function JSify(data, functionsOnly, givenFunctions) { ret += value + '{\n'; } var phiSet = getPhiSetsForLabel(phiSets, targetLabel); - ret += ' ' + phiSet + makeBranch(targetLabel, item.currLabelId || null) + '\n'; + ret += INDENTATION + '' + phiSet + makeBranch(targetLabel, item.currLabelId || null) + '\n'; ret += '}\n'; if (RELOOP) { item.groupedLabels.push({ From fb9b76bd934414969e90b75671fd4c64bf689246 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 21 Jun 2013 14:47:12 -0700 Subject: [PATCH 51/51] reduce indentation in relooper --- src/relooper/Relooper.cpp | 10 +- src/relooper/test.txt | 108 +++--- src/relooper/test2.txt | 12 +- src/relooper/test3.txt | 34 +- src/relooper/test4.txt | 24 +- src/relooper/test5.txt | 46 +-- src/relooper/test6.txt | 12 +- src/relooper/test_debug.txt | 12 +- src/relooper/test_fuzz1.txt | 40 +-- src/relooper/test_fuzz2.txt | 10 +- src/relooper/test_fuzz3.txt | 2 +- src/relooper/test_fuzz4.txt | 16 +- src/relooper/test_fuzz5.txt | 82 ++--- src/relooper/test_fuzz6.txt | 186 +++++----- src/relooper/test_inf.txt | 698 ++++++++++++++++++------------------ tools/shared.py | 2 +- 16 files changed, 648 insertions(+), 646 deletions(-) diff --git a/src/relooper/Relooper.cpp b/src/relooper/Relooper.cpp index 7ceeb2f829f8e..aa7e71a133a9b 100644 --- a/src/relooper/Relooper.cpp +++ b/src/relooper/Relooper.cpp @@ -18,6 +18,8 @@ static void PrintDebug(const char *Format, ...); #define DebugDump(x, ...) #endif +#define INDENTATION 1 + struct Indenter { static int CurrIndent; @@ -34,8 +36,8 @@ static int OutputBufferSize = 0; void PrintIndented(const char *Format, ...) { assert(OutputBuffer); - assert(OutputBuffer + Indenter::CurrIndent*2 - OutputBufferRoot < OutputBufferSize); - for (int i = 0; i < Indenter::CurrIndent*2; i++, OutputBuffer++) *OutputBuffer = ' '; + assert(OutputBuffer + Indenter::CurrIndent*INDENTATION - OutputBufferRoot < OutputBufferSize); + for (int i = 0; i < Indenter::CurrIndent*INDENTATION; i++, OutputBuffer++) *OutputBuffer = ' '; va_list Args; va_start(Args, Format); int left = OutputBufferSize - (OutputBuffer - OutputBufferRoot); @@ -47,8 +49,8 @@ void PrintIndented(const char *Format, ...) { void PutIndented(const char *String) { assert(OutputBuffer); - assert(OutputBuffer + Indenter::CurrIndent*2 - OutputBufferRoot < OutputBufferSize); - for (int i = 0; i < Indenter::CurrIndent*2; i++, OutputBuffer++) *OutputBuffer = ' '; + assert(OutputBuffer + Indenter::CurrIndent*INDENTATION - OutputBufferRoot < OutputBufferSize); + for (int i = 0; i < Indenter::CurrIndent*INDENTATION; i++, OutputBuffer++) *OutputBuffer = ' '; int left = OutputBufferSize - (OutputBuffer - OutputBufferRoot); int needed = strlen(String)+1; assert(needed < left); diff --git a/src/relooper/test.txt b/src/relooper/test.txt index b35355928f9a3..6c9108465c700 100644 --- a/src/relooper/test.txt +++ b/src/relooper/test.txt @@ -6,11 +6,11 @@ // block A if (check == 10) { - atob(); - // block B - btoc(); + atob(); + // block B + btoc(); } else { - atoc(); + atoc(); } // block C @@ -22,9 +22,9 @@ if (check == 10) { // block A if (check == 15) { - // block B + // block B } else { - // block C + // block C } // block D @@ -35,12 +35,12 @@ if (check == 15) { while(1) { - // block A - var check = maybe(); - // block B - if (!(check == 41)) { - break; - } + // block A + var check = maybe(); + // block B + if (!(check == 41)) { + break; + } } // block C @@ -51,25 +51,25 @@ while(1) { // code 1 var $i_0 = 0;var $x_0 = 5; while(1) { - // code 2 - if (!($2)) { - var $x_1 = $x_0; - label = 18; - break; - } - // code 3 - if ($6) { - break; - } else { - var $i_0 = $7;var $x_0 = $5; - } + // code 2 + if (!($2)) { + var $x_1 = $x_0; + label = 18; + break; + } + // code 3 + if ($6) { + break; + } else { + var $i_0 = $7;var $x_0 = $5; + } } if (label == 18) { - // code 7 + // code 7 } // code 4 if ($10) { - // code 5 + // code 5 } // code 6 var $x_1 = $13; @@ -83,15 +83,15 @@ var $x_1 = $13; // block A................................................................................................... if (chak()) { - atob(); - // block B................................................................................................... - btod(); - // block D + atob(); + // block B................................................................................................... + btod(); + // block D } else { - atoc(); - // block C................................................................................................... - ctod2(); - // block D + atoc(); + // block C................................................................................................... + ctod2(); + // block D } @@ -102,11 +102,11 @@ if (chak()) { // block A if (!(check == 10)) { - return C; + return C; } while(1) { - // block B - // block D + // block B + // block D } @@ -117,23 +117,23 @@ while(1) { // block A do { - if (expensive()) { - label = 33; - } else { - // block B - if (expensive2()) { - label = 33; - break; - } - // block D + if (expensive()) { + label = 33; + } else { + // block B + if (expensive2()) { + label = 33; + break; } + // block D + } } while(0); if (label == 33) { - // block C; + // block C; } while(1) { - // block E - // block F + // block E + // block F } @@ -144,12 +144,12 @@ while(1) { // block A if (shouldLoop()) { - while(1) { - // block B - if (!(moarLoop())) { - break; - } + while(1) { + // block B + if (!(moarLoop())) { + break; } + } } // block C diff --git a/src/relooper/test2.txt b/src/relooper/test2.txt index c77ce49128361..2f3e5ca11efbc 100644 --- a/src/relooper/test2.txt +++ b/src/relooper/test2.txt @@ -1,12 +1,12 @@ ep do { - if (ep -> LBB1) { - LBB1 - if (!(LBB1 -> LBB2)) { - break; - } - LBB2 + if (ep -> LBB1) { + LBB1 + if (!(LBB1 -> LBB2)) { + break; } + LBB2 + } } while(0); LBB3 diff --git a/src/relooper/test3.txt b/src/relooper/test3.txt index 6049ee48fabd1..51199f72a05b8 100644 --- a/src/relooper/test3.txt +++ b/src/relooper/test3.txt @@ -1,27 +1,27 @@ ep do { - if (ep -> LBB1) { - LBB1 - if (!(LBB1 -> LBB2)) { - break; - } - LBB2 + if (ep -> LBB1) { + LBB1 + if (!(LBB1 -> LBB2)) { + break; } + LBB2 + } } while(0); LBB3 do { - if (LBB3 -> LBB4) { - LBB4 - if (!(LBB4 -> LBB5)) { - break; - } - while(1) { - LBB5 - if (LBB5 -> LBB6) { - break; - } - } + if (LBB3 -> LBB4) { + LBB4 + if (!(LBB4 -> LBB5)) { + break; } + while(1) { + LBB5 + if (LBB5 -> LBB6) { + break; + } + } + } } while(0); LBB6 diff --git a/src/relooper/test4.txt b/src/relooper/test4.txt index 3427ff1831e13..ab7051c1faa29 100644 --- a/src/relooper/test4.txt +++ b/src/relooper/test4.txt @@ -1,23 +1,23 @@ //19 do { - if ( 1 ) { - //20 - if (!( 1 )) { - label = 4; - break; - } - //21 - } else { - label = 4; + if ( 1 ) { + //20 + if (!( 1 )) { + label = 4; + break; } + //21 + } else { + label = 4; + } } while(0); if (label == 4) { - //22 + //22 } //23 if ( 1 ) { - //24 + //24 } else { - //28 + //28 } diff --git a/src/relooper/test5.txt b/src/relooper/test5.txt index ad769ae7bb0b3..83755289a42bf 100644 --- a/src/relooper/test5.txt +++ b/src/relooper/test5.txt @@ -1,32 +1,32 @@ //0 if (check(0)) { - while(1) { - //1 - if (!(check(1))) { - break; - } + while(1) { + //1 + if (!(check(1))) { + break; } - while(1) { - //2 - if (!(check(2))) { - break; - } + } + while(1) { + //2 + if (!(check(2))) { + break; } - //3 + } + //3 } else { - goingFrom0to4(); - while(1) { - //4 - if (!(check(4))) { - break; - } + goingFrom0to4(); + while(1) { + //4 + if (!(check(4))) { + break; } - while(1) { - //5 - if (check(5)) { - break; - } + } + while(1) { + //5 + if (check(5)) { + break; } - //3 + } + //3 } diff --git a/src/relooper/test6.txt b/src/relooper/test6.txt index c5effd0887043..4f29f292a504a 100644 --- a/src/relooper/test6.txt +++ b/src/relooper/test6.txt @@ -1,12 +1,12 @@ //0 do { - if (check(0)) { - //1 - if (!(check(1))) { - break; - } - //2 + if (check(0)) { + //1 + if (!(check(1))) { + break; } + //2 + } } while(0); //3 diff --git a/src/relooper/test_debug.txt b/src/relooper/test_debug.txt index d18ed875c6702..4a42e64213e5b 100644 --- a/src/relooper/test_debug.txt +++ b/src/relooper/test_debug.txt @@ -116,13 +116,13 @@ int main() { // Fusing Multiple to Simple ep do { - if (ep -> LBB1) { - LBB1 - if (!(LBB1 -> LBB2)) { - break; - } - LBB2 + if (ep -> LBB1) { + LBB1 + if (!(LBB1 -> LBB2)) { + break; } + LBB2 + } } while(0); LBB3 diff --git a/src/relooper/test_fuzz1.txt b/src/relooper/test_fuzz1.txt index b278e240434b3..becbc0d2c5db2 100644 --- a/src/relooper/test_fuzz1.txt +++ b/src/relooper/test_fuzz1.txt @@ -4,29 +4,29 @@ print('entry'); var label; var state; var decisions = [4, 1, 7, 2, 6, 6, 8]; var print(5); state = check(); print(6); state = check(); if (state == 7) { - print(7); state = check(); - label = 3; + print(7); state = check(); + label = 3; } L5: while(1) { - if (label == 3) { - label = 0; - print(2); state = check(); + if (label == 3) { + label = 0; + print(2); state = check(); + } + print(1); state = check(); + while(1) { + print(3); state = check(); + if (!(state == 8)) { + continue L5; } - print(1); state = check(); - while(1) { - print(3); state = check(); - if (!(state == 8)) { - continue L5; - } - print(8); state = check(); - if (!(state == 4)) { - label = 3; - continue L5; - } - print(4); state = check(); - if (!(state == 3)) { - continue L5; - } + print(8); state = check(); + if (!(state == 4)) { + label = 3; + continue L5; } + print(4); state = check(); + if (!(state == 3)) { + continue L5; + } + } } diff --git a/src/relooper/test_fuzz2.txt b/src/relooper/test_fuzz2.txt index 572e819de2ed7..02b2c83be98d7 100644 --- a/src/relooper/test_fuzz2.txt +++ b/src/relooper/test_fuzz2.txt @@ -2,12 +2,12 @@ print('entry'); var label; var state; var decisions = [4, 1, 4, 3, 4, 1, 2, 5, 1, 3, 5, 5, 1, 5, 2, 4, 4, 3]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] } if (state == 1) { - while(1) { - print(1); state = check(); - } + while(1) { + print(1); state = check(); + } } while(1) { - print(3); state = check(); - print(2); state = check(); + print(3); state = check(); + print(2); state = check(); } diff --git a/src/relooper/test_fuzz3.txt b/src/relooper/test_fuzz3.txt index aeeccf8731503..b4b1831ddbc22 100644 --- a/src/relooper/test_fuzz3.txt +++ b/src/relooper/test_fuzz3.txt @@ -4,6 +4,6 @@ print('entry'); var label; var state; var decisions = [3, 3, 4, 1, 2, 1, 2, 4, 4 print(1); state = check(); print(3); state = check(); while(1) { - print(4); state = check(); + print(4); state = check(); } diff --git a/src/relooper/test_fuzz4.txt b/src/relooper/test_fuzz4.txt index 05a70582a2554..766ebdb64f451 100644 --- a/src/relooper/test_fuzz4.txt +++ b/src/relooper/test_fuzz4.txt @@ -2,18 +2,18 @@ print('entry'); var label; var state; var decisions = [2, 2, 1, 3, 2, 2, 1, 3, 2, 3, 3, 1, 3, 2, 1]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] } if (state == 2) { - while(1) { - print(2); state = check(); - } + while(1) { + print(2); state = check(); + } } while(1) { - print(4); state = check(); - if (!(state == 4)) { - break; - } + print(4); state = check(); + if (!(state == 4)) { + break; + } } print(3); state = check(); while(1) { - print(1); state = check(); + print(1); state = check(); } diff --git a/src/relooper/test_fuzz5.txt b/src/relooper/test_fuzz5.txt index 29b2dba43e4d0..0f76d1ed76b7b 100644 --- a/src/relooper/test_fuzz5.txt +++ b/src/relooper/test_fuzz5.txt @@ -2,51 +2,51 @@ print('entry'); var label; var state; var decisions = [133, 98, 134, 143, 162, 187, 130, 87, 91, 49, 102, 47, 9, 132, 179, 176, 157, 25, 64, 161, 57, 107, 16, 167, 185, 45, 191, 180, 23, 131]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] } L1: while(1) { - print(7); state = check(); - if (state % 3 == 1) { - label = 3; - } else if (state % 3 == 0) { - print(8); state = check(); - if (state % 2 == 0) { - label = 5; - } else { - label = 7; - } + print(7); state = check(); + if (state % 3 == 1) { + label = 3; + } else if (state % 3 == 0) { + print(8); state = check(); + if (state % 2 == 0) { + label = 5; } else { - break; + label = 7; } - while(1) { - if (label == 3) { - label = 0; - print(2); state = check(); - print(1); state = check(); - if (state % 2 == 0) { - label = 5; - continue; - } else { - label = 7; - continue; - } - } - else if (label == 5) { - label = 0; - print(4); state = check(); - label = 3; - continue; - } - else if (label == 7) { - label = 0; - print(6); state = check(); - if (state % 2 == 0) { - continue L1; - } else { - label = 7; - continue; - } - } + } else { + break; + } + while(1) { + if (label == 3) { + label = 0; + print(2); state = check(); + print(1); state = check(); + if (state % 2 == 0) { + label = 5; + continue; + } else { + label = 7; + continue; + } } + else if (label == 5) { + label = 0; + print(4); state = check(); + label = 3; + continue; + } + else if (label == 7) { + label = 0; + print(6); state = check(); + if (state % 2 == 0) { + continue L1; + } else { + label = 7; + continue; + } + } + } } while(1) { - print(3); state = check(); + print(3); state = check(); } diff --git a/src/relooper/test_fuzz6.txt b/src/relooper/test_fuzz6.txt index d5a5ab7bb0ee8..cd93958c677a4 100644 --- a/src/relooper/test_fuzz6.txt +++ b/src/relooper/test_fuzz6.txt @@ -2,107 +2,107 @@ print('entry'); var label; var state; var decisions = [759, 1223, 618, 1805, 277, 512, 204, 1545, 606, 734, 585, 447, 1670, 1031, 665, 1728, 353, 634, 1033, 13, 658, 589, 474, 854, 405, 1111, 1640, 697, 1156, 1357, 317, 618, 990, 1401, 405, 564, 497, 829, 653, 1194, 25, 322, 1178, 198, 1565, 1419, 1608, 486, 368, 606, 813, 22, 148, 141, 261, 375, 472, 964, 1106, 694, 205, 771, 44, 675, 545, 1027, 1528, 240, 1289, 564, 792, 744, 366, 668, 823, 210, 428, 1009, 1662, 1317, 1183, 681, 14, 1334, 712, 506, 224, 695, 401, 1035, 384, 486, 1519, 122, 1186, 1487, 1819, 1702, 463, 1706, 660, 1642, 847, 991, 976, 940, 867, 46, 23, 1449, 56, 1711, 634, 404, 1558, 168, 710, 1581, 1302, 870, 997, 1295, 1739, 769, 1005, 291, 1638, 1771, 842, 659, 1695, 713, 935, 802, 1173, 1572, 850, 607, 996, 55, 1576, 321, 1815, 662, 1044, 1612, 1680, 1050, 844, 553, 278, 1447, 1662, 1094, 1797, 774, 1013, 1204, 907, 340, 1172, 1460, 869, 1264, 111, 1176, 484, 845, 258, 417, 1246, 1017, 745, 189, 333, 1658, 1395, 1764, 1786, 165, 404, 847, 1429, 1574, 403, 718, 1118, 1756, 94, 56, 1498, 1696, 1355, 840, 50, 82, 371, 1087, 875, 1337, 267, 958, 1209, 1167, 1025, 1684, 184, 962, 1496, 201, 127, 372, 1, 1005, 402, 1387, 213, 1143, 1271, 167, 10, 12, 1060, 1390, 1366, 893, 747, 1005, 481, 876, 227, 514, 589, 250, 273, 1188, 1052, 719, 219, 1006, 38, 120, 1454, 489, 672, 149, 534, 1081, 1721, 586, 330, 25, 356, 1743, 1607, 336, 981, 419, 1036, 1293, 1026, 1300, 1453, 792, 22, 45, 420, 409, 1027, 1437, 1421, 795, 136, 1276, 1610, 1593]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] } while(1) { - print(30); state = check();// ................................................................................................................................................................................................................. - if (state % 3 == 1) { - label = 67; - break; - } else if (!(state % 3 == 0)) { - break; - } - print(58); state = check();// ...................................................................................... + print(30); state = check();// ................................................................................................................................................................................................................. + if (state % 3 == 1) { + label = 67; + break; + } else if (!(state % 3 == 0)) { + break; + } + print(58); state = check();// ...................................................................................... } if (label == 67) { - print(66); state = check();// ............................................................................................................... + print(66); state = check();// ............................................................................................................... } print(6); state = check();// ......... while(1) { - print(88); state = check();// .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... - print(70); state = check();// .......................................................................................................................... - L10: while(1) { - print(47); state = check();// .................................................................................................................................... - print(28); state = check();// .............................................................................................................. - while(1) { - print(75); state = check();// ............................................. - print(7); state = check();// ............................................................................................................................................................................................. - if (!(state % 2 == 0)) { - break; - } + print(88); state = check();// .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... + print(70); state = check();// .......................................................................................................................... + L10: while(1) { + print(47); state = check();// .................................................................................................................................... + print(28); state = check();// .............................................................................................................. + while(1) { + print(75); state = check();// ............................................. + print(7); state = check();// ............................................................................................................................................................................................. + if (!(state % 2 == 0)) { + break; + } + } + print(89); state = check();// ...................................................................................................................................................................................................................................................................................................................................................... + print(68); state = check();// ...................................................................................................................................................................................................................................................................................................................... + L18: while(1) { + print(51); state = check();// ............................................................................................. + L20: while(1) { + print(36); state = check();// ......................... + if (state % 2 == 0) { + break; } - print(89); state = check();// ...................................................................................................................................................................................................................................................................................................................................................... - print(68); state = check();// ...................................................................................................................................................................................................................................................................................................................... - L18: while(1) { - print(51); state = check();// ............................................................................................. - L20: while(1) { - print(36); state = check();// ......................... - if (state % 2 == 0) { - break; - } - print(16); state = check();// ................................................................................................................................................................................................................................................................................................................................................................ - print(57); state = check();// ........................................................................................................................................................................................................................................................................................................................... - print(39); state = check();// ................ - if (state % 3 == 1) { - label = 74; - } else if (!(state % 3 == 0)) { - label = 32; - break; - } - while(1) { - if (label == 74) { - label = 0; - print(73); state = check();// . - if (state % 3 == 1) { - label = 32; - break L20; - } else if (state % 3 == 0) { - break; - } - print(43); state = check();// ......... - print(32); state = check();// ...................................................................................................... - print(83); state = check();// ........................................................................................ - print(77); state = check();// ........................................................................................................................................................................................................................................................................................... - print(76); state = check();// .............................................................................................................................................................................................................................................................................................................................................................................................................................. - print(22); state = check();// ......................................................................................................... - } - print(72); state = check();// .......................................................................................................... - if (state % 2 == 0) { - label = 92; - break L20; - } - print(80); state = check();// .................................... - if (state % 2 == 0) { - continue L18; - } - print(50); state = check();// ........................................ - print(29); state = check();// ............... - print(8); state = check();// .................................................................................................................................................................................................................................................... - if (state % 2 == 0) { - continue L10; - } - print(19); state = check();// ...................................................................................................................................................................................................................... - print(56); state = check();// .................................................................................................................................................................................................................... - print(34); state = check();// .......................................................................................................................................... - label = 74; - } - print(62); state = check();// ....................................................................................... - } - if (label == 32) { - label = 0; - print(31); state = check();// .......................................................................................................................................................................................................... - } - else if (label == 92) { - label = 0; - print(91); state = check();// .............................................. - print(33); state = check();// .... - } - print(60); state = check();// ...................................................................................................................................................................................................................................... - print(10); state = check();// ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... - print(52); state = check();// .............................................................................. - if (state % 2 == 0) { - break L10; + print(16); state = check();// ................................................................................................................................................................................................................................................................................................................................................................ + print(57); state = check();// ........................................................................................................................................................................................................................................................................................................................... + print(39); state = check();// ................ + if (state % 3 == 1) { + label = 74; + } else if (!(state % 3 == 0)) { + label = 32; + break; + } + while(1) { + if (label == 74) { + label = 0; + print(73); state = check();// . + if (state % 3 == 1) { + label = 32; + break L20; + } else if (state % 3 == 0) { + break; } - print(2); state = check();// ......... + print(43); state = check();// ......... + print(32); state = check();// ...................................................................................................... + print(83); state = check();// ........................................................................................ + print(77); state = check();// ........................................................................................................................................................................................................................................................................................... + print(76); state = check();// .............................................................................................................................................................................................................................................................................................................................................................................................................................. + print(22); state = check();// ......................................................................................................... + } + print(72); state = check();// .......................................................................................................... + if (state % 2 == 0) { + label = 92; + break L20; + } + print(80); state = check();// .................................... + if (state % 2 == 0) { + continue L18; + } + print(50); state = check();// ........................................ + print(29); state = check();// ............... + print(8); state = check();// .................................................................................................................................................................................................................................................... + if (state % 2 == 0) { + continue L10; + } + print(19); state = check();// ...................................................................................................................................................................................................................... + print(56); state = check();// .................................................................................................................................................................................................................... + print(34); state = check();// .......................................................................................................................................... + label = 74; } + print(62); state = check();// ....................................................................................... + } + if (label == 32) { + label = 0; + print(31); state = check();// .......................................................................................................................................................................................................... + } + else if (label == 92) { + label = 0; + print(91); state = check();// .............................................. + print(33); state = check();// .... + } + print(60); state = check();// ...................................................................................................................................................................................................................................... + print(10); state = check();// ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... + print(52); state = check();// .............................................................................. + if (state % 2 == 0) { + break L10; + } + print(2); state = check();// ......... } - print(61); state = check();// ......................................................................................................................................................... + } + print(61); state = check();// ......................................................................................................................................................... } diff --git a/src/relooper/test_inf.txt b/src/relooper/test_inf.txt index 1dff59bba0e77..bc2fad3e9e1ea 100644 --- a/src/relooper/test_inf.txt +++ b/src/relooper/test_inf.txt @@ -1,385 +1,385 @@ code 0 if (uint(i4) >= uint(i5)) { - code 2 + code 2 } else { - code 1 + code 1 } code 3 if (!(i2 == 0)) { - code 4 - while(1) { - code 5 - if (uint(i6) >= uint(i7)) { - code 7 - } else { - code 6 - } - code 8 - if (uint(i6) >= uint(i7)) { - code 10 - } else { - code 9 - } - code 11 - if (uint(i5) >= uint(i6)) { - code 13 - } else { - code 12 - } - code 14 - if (!(i2 != 0)) { - break; - } + code 4 + while(1) { + code 5 + if (uint(i6) >= uint(i7)) { + code 7 + } else { + code 6 + } + code 8 + if (uint(i6) >= uint(i7)) { + code 10 + } else { + code 9 + } + code 11 + if (uint(i5) >= uint(i6)) { + code 13 + } else { + code 12 } + code 14 + if (!(i2 != 0)) { + break; + } + } } code 15 if (uint(i4) >= uint(i5)) { - code 17 + code 17 } else { - code 16 + code 16 } code 18 if (!(i2 == 0)) { - code 19 - while(1) { - code 20 - if (uint(i5) >= uint(i6)) { - code 22 - } else { - code 21 - } - code 23 - if (uint(i5) >= uint(i6)) { - code 25 - } else { - code 24 - } - code 26 - if (uint(i5) >= uint(i6)) { - code 28 - } else { - code 27 - } - code 29 - if (uint(i5) >= uint(i6)) { - code 31 - } else { - code 30 - } - code 32 - if (uint(i5) >= uint(i6)) { - code 34 - } else { - code 33 - } - code 35 - if (uint(i5) >= uint(i6)) { - code 37 - } else { - code 36 - } - code 38 - if (uint(i5) >= uint(i6)) { - code 40 - } else { - code 39 - } - code 41 - if (uint(i5) >= uint(i6)) { - code 43 - } else { - code 42 - } - code 44 - if (uint(i5) >= uint(i6)) { - code 46 - } else { - code 45 - } - code 47 - if (uint(i5) >= uint(i6)) { - code 49 - } else { - code 48 - } - code 50 - if (uint(i5) >= uint(i6)) { - code 52 - } else { - code 51 - } - code 53 - if (uint(i5) >= uint(i6)) { - code 55 - } else { - code 54 - } - code 56 - if (uint(i5) >= uint(i6)) { - code 58 - } else { - code 57 - } - code 59 - if (uint(i5) >= uint(i6)) { - code 61 - } else { - code 60 - } - code 62 - if (uint(i5) >= uint(i6)) { - code 64 - } else { - code 63 - } - code 65 - if (uint(i5) >= uint(i6)) { - code 67 - } else { - code 66 - } - code 68 - if (uint(i5) >= uint(i6)) { - code 70 - } else { - code 69 - } - code 71 - if (uint(i5) >= uint(i6)) { - code 73 - } else { - code 72 - } - code 74 - if (uint(i5) >= uint(i6)) { - code 76 - } else { - code 75 - } - code 77 - if (uint(i5) >= uint(i6)) { - code 79 - } else { - code 78 - } - code 80 - if (uint(i5) >= uint(i6)) { - code 82 - } else { - code 81 - } - code 83 - if (uint(i5) >= uint(i6)) { - code 85 - } else { - code 84 - } - code 86 - if (uint(i5) >= uint(i6)) { - code 88 - } else { - code 87 - } - code 89 - if (uint(i5) >= uint(i6)) { - code 91 - } else { - code 90 - } - code 92 - if (uint(i5) >= uint(i6)) { - code 94 - } else { - code 93 - } - code 95 - if (uint(i5) >= uint(i6)) { - code 97 - } else { - code 96 - } - code 98 - if (uint(i5) >= uint(i6)) { - code 100 - } else { - code 99 - } - code 101 - if (!(i2 != 0)) { - break; - } + code 19 + while(1) { + code 20 + if (uint(i5) >= uint(i6)) { + code 22 + } else { + code 21 } + code 23 + if (uint(i5) >= uint(i6)) { + code 25 + } else { + code 24 + } + code 26 + if (uint(i5) >= uint(i6)) { + code 28 + } else { + code 27 + } + code 29 + if (uint(i5) >= uint(i6)) { + code 31 + } else { + code 30 + } + code 32 + if (uint(i5) >= uint(i6)) { + code 34 + } else { + code 33 + } + code 35 + if (uint(i5) >= uint(i6)) { + code 37 + } else { + code 36 + } + code 38 + if (uint(i5) >= uint(i6)) { + code 40 + } else { + code 39 + } + code 41 + if (uint(i5) >= uint(i6)) { + code 43 + } else { + code 42 + } + code 44 + if (uint(i5) >= uint(i6)) { + code 46 + } else { + code 45 + } + code 47 + if (uint(i5) >= uint(i6)) { + code 49 + } else { + code 48 + } + code 50 + if (uint(i5) >= uint(i6)) { + code 52 + } else { + code 51 + } + code 53 + if (uint(i5) >= uint(i6)) { + code 55 + } else { + code 54 + } + code 56 + if (uint(i5) >= uint(i6)) { + code 58 + } else { + code 57 + } + code 59 + if (uint(i5) >= uint(i6)) { + code 61 + } else { + code 60 + } + code 62 + if (uint(i5) >= uint(i6)) { + code 64 + } else { + code 63 + } + code 65 + if (uint(i5) >= uint(i6)) { + code 67 + } else { + code 66 + } + code 68 + if (uint(i5) >= uint(i6)) { + code 70 + } else { + code 69 + } + code 71 + if (uint(i5) >= uint(i6)) { + code 73 + } else { + code 72 + } + code 74 + if (uint(i5) >= uint(i6)) { + code 76 + } else { + code 75 + } + code 77 + if (uint(i5) >= uint(i6)) { + code 79 + } else { + code 78 + } + code 80 + if (uint(i5) >= uint(i6)) { + code 82 + } else { + code 81 + } + code 83 + if (uint(i5) >= uint(i6)) { + code 85 + } else { + code 84 + } + code 86 + if (uint(i5) >= uint(i6)) { + code 88 + } else { + code 87 + } + code 89 + if (uint(i5) >= uint(i6)) { + code 91 + } else { + code 90 + } + code 92 + if (uint(i5) >= uint(i6)) { + code 94 + } else { + code 93 + } + code 95 + if (uint(i5) >= uint(i6)) { + code 97 + } else { + code 96 + } + code 98 + if (uint(i5) >= uint(i6)) { + code 100 + } else { + code 99 + } + code 101 + if (!(i2 != 0)) { + break; + } + } } code 102 if (uint(i4) >= uint(i5)) { - code 104 + code 104 } else { - code 103 + code 103 } code 105 if (!(i2 == 0)) { - code 106 - while(1) { - code 107 - if (uint(i5) >= uint(i6)) { - code 109 - } else { - code 108 - } - code 110 - if (uint(i5) >= uint(i6)) { - code 112 - } else { - code 111 - } - code 113 - if (uint(i5) >= uint(i6)) { - code 115 - } else { - code 114 - } - code 116 - if (uint(i5) >= uint(i6)) { - code 118 - } else { - code 117 - } - code 119 - if (uint(i5) >= uint(i6)) { - code 121 - } else { - code 120 - } - code 122 - if (uint(i5) >= uint(i6)) { - code 124 - } else { - code 123 - } - code 125 - if (uint(i5) >= uint(i6)) { - code 127 - } else { - code 126 - } - code 128 - if (uint(i5) >= uint(i6)) { - code 130 - } else { - code 129 - } - code 131 - if (uint(i5) >= uint(i6)) { - code 133 - } else { - code 132 - } - code 134 - if (uint(i5) >= uint(i6)) { - code 136 - } else { - code 135 - } - code 137 - if (uint(i5) >= uint(i6)) { - code 139 - } else { - code 138 - } - code 140 - if (uint(i5) >= uint(i6)) { - code 142 - } else { - code 141 - } - code 143 - if (uint(i5) >= uint(i6)) { - code 145 - } else { - code 144 - } - code 146 - if (uint(i5) >= uint(i6)) { - code 148 - } else { - code 147 - } - code 149 - if (uint(i5) >= uint(i6)) { - code 151 - } else { - code 150 - } - code 152 - if (uint(i5) >= uint(i6)) { - code 154 - } else { - code 153 - } - code 155 - if (uint(i5) >= uint(i6)) { - code 157 - } else { - code 156 - } - code 158 - if (uint(i5) >= uint(i6)) { - code 160 - } else { - code 159 - } - code 161 - if (uint(i5) >= uint(i6)) { - code 163 - } else { - code 162 - } - code 164 - if (uint(i5) >= uint(i6)) { - code 166 - } else { - code 165 - } - code 167 - if (!(i2 != 0)) { - break; - } + code 106 + while(1) { + code 107 + if (uint(i5) >= uint(i6)) { + code 109 + } else { + code 108 } -} -code 168 -if (uint(i4) >= uint(i5)) { - code 170 -} else { - code 169 -} -code 171 -if (i2 == 0) { - code 183 -} -code 172 -while(1) { - code 173 + code 110 + if (uint(i5) >= uint(i6)) { + code 112 + } else { + code 111 + } + code 113 + if (uint(i5) >= uint(i6)) { + code 115 + } else { + code 114 + } + code 116 + if (uint(i5) >= uint(i6)) { + code 118 + } else { + code 117 + } + code 119 + if (uint(i5) >= uint(i6)) { + code 121 + } else { + code 120 + } + code 122 + if (uint(i5) >= uint(i6)) { + code 124 + } else { + code 123 + } + code 125 + if (uint(i5) >= uint(i6)) { + code 127 + } else { + code 126 + } + code 128 + if (uint(i5) >= uint(i6)) { + code 130 + } else { + code 129 + } + code 131 + if (uint(i5) >= uint(i6)) { + code 133 + } else { + code 132 + } + code 134 + if (uint(i5) >= uint(i6)) { + code 136 + } else { + code 135 + } + code 137 + if (uint(i5) >= uint(i6)) { + code 139 + } else { + code 138 + } + code 140 + if (uint(i5) >= uint(i6)) { + code 142 + } else { + code 141 + } + code 143 + if (uint(i5) >= uint(i6)) { + code 145 + } else { + code 144 + } + code 146 + if (uint(i5) >= uint(i6)) { + code 148 + } else { + code 147 + } + code 149 if (uint(i5) >= uint(i6)) { - code 175 + code 151 } else { - code 174 + code 150 } - code 176 + code 152 if (uint(i5) >= uint(i6)) { - code 178 + code 154 } else { - code 177 + code 153 } - code 179 - if (uint(i4) >= uint(i5)) { - code 181 + code 155 + if (uint(i5) >= uint(i6)) { + code 157 + } else { + code 156 + } + code 158 + if (uint(i5) >= uint(i6)) { + code 160 + } else { + code 159 + } + code 161 + if (uint(i5) >= uint(i6)) { + code 163 + } else { + code 162 + } + code 164 + if (uint(i5) >= uint(i6)) { + code 166 } else { - code 180 + code 165 } - code 182 + code 167 if (!(i2 != 0)) { - break; + break; } + } +} +code 168 +if (uint(i4) >= uint(i5)) { + code 170 +} else { + code 169 +} +code 171 +if (i2 == 0) { + code 183 +} +code 172 +while(1) { + code 173 + if (uint(i5) >= uint(i6)) { + code 175 + } else { + code 174 + } + code 176 + if (uint(i5) >= uint(i6)) { + code 178 + } else { + code 177 + } + code 179 + if (uint(i4) >= uint(i5)) { + code 181 + } else { + code 180 + } + code 182 + if (!(i2 != 0)) { + break; + } } code 183 diff --git a/tools/shared.py b/tools/shared.py index c16c91154af85..db8f7a5687eb3 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -295,7 +295,7 @@ def check_node_version(): # we re-check sanity when the settings are changed) # We also re-check sanity and clear the cache when the version changes -EMSCRIPTEN_VERSION = '1.5.0' +EMSCRIPTEN_VERSION = '1.5.1' def generate_sanity(): return EMSCRIPTEN_VERSION + '|' + get_llvm_target()